Wednesday, October 1, 2014

Re: 1 named url per page/screen?

Ok, thank you Daniel. Your response is reasonable and makes sense, but that clarity is not on the docs page. But this leads me to a related follow up: The need for the parameter, be it 'green' as in my case or '1945' as in the docs, means that each template is going to be tied to a single web page. So instead of hardcoding the url, we are hardcoding the template, meaning it can't be re-used, even if the only difference between it and the copy is 'yellow' instead of 'green'. 

In other words, two documents in the same namespace, with the same view and the same regex/url pattern, can't be reversed unless you include a distinguishing, unique parameter in the url tag. And this unique parameter has to be 'hardcoded', it can't be a variable. That doesn't make sense to me either. In fact, once I fixed the part about empty strings being passed, and I figured out why I was getting no reverse match, Django was able to decipher the right parameter without me hardcoding it in the url tag, so I completely don't understand what is going on there. If you'd care to enlighten me, please do.

But I am not out of the woods yet. I posted a new request for help here: https://groups.google.com/forum/#!topic/django-users/fbiVWytyz5w 

. I invite you to share your wisdom.



On Thursday, September 25, 2014 4:43:43 PM UTC-5, Malik Rumi wrote:
1. I am trying to understand the documentation here: https://docs.djangoproject.com/en/1.7/topics/http/urls/#naming-url-patterns

Let us suppose I have a model and folder on mysite called Colors. Within Colors there are several individual documents: blue, green, yellow.

If blue, green, and yellow all use the same view and template, [and they're supposed to, aren't they?]  does this mean each url must be named 'blue' or 'green' or 'yellow' in order for Django to tell them apart?

That's how I'm reading this, but that doesn't make sense to me, because it seems to be about the same as hardcoding the url, and if you have a lot of pages it would be murder to have to do this for every page, and seems contrary to the whole notion of a dynamic web site.  So what am I missing here?



2. I am struggling with this error: 

" Reverse for 'colors_articleView' with arguments '()' and keyword arguments '{u'pk': '', u'slug': ''}' not found. 1 pattern(s) tried: ['colors/(?P<pk>\\d+)/(?P<slug>[\\w]+)'] "

I don't know what I'm missing here. I did a queryset for all the colors in a function based equivalent to list view and didn't see this error, but now that I want individual pages I can't resolve it. 



thx.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/0b0d6e7e-497b-47d3-bd25-38184f897871%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment