> On Wednesday, 2 November 2011 07:24:39 UTC, rihad wrote:
>
> > It says at the end of part 3 of the Django tutorial:
>
> > "The idea behind include() and URLconf decoupling is to make it easy
> > to plug-and-play URLs. Now that polls are in their own URLconf, they
> > can be placed under "/polls/", or under "/fun_polls/", or under "/
> > content/polls/", or any other path root, and the app will still work."
>
> > It's actually not that simple. Simply changing the project-wide
> > URLconf prefix from '^polls/' to '^fun_polls/' will not work, because
> > the code referencing templates still has polls in its path:
> > render_to_response('polls/detail.html', {'poll': p})
> > or in URLs:
> > <a href="/polls/{{ poll.id }}/">{{ poll.question }}</a>
>
> Your first point is simply not true. Changing the urlconf prefix does not
> in any way affect how you reference the template path. You could prefix the
> polls URLs with 'foobar', but the template path would still be 'polls'.
>
> The second point is made irrelevant by something that's not covered in the
> tutorial, but is mentioned in the actual documentation for URLs: you should
> never hard-code URLs, you should use the `{% url %}` tag in templates or
> the `reverse()` function in views - for precisely this reason.
> --
Thanks, now I see.
p.s.: don't know where you saw two points. All I meant was that simply
changing /polls/ to /fun_polls/ will not work with the code examples
given up to that point in the tutorial, as implied by it, precisely
because URLs in the app are coupled to urlpatterns. The second part
seems to be the answer, though.
--
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
No comments:
Post a Comment