views:

25

answers:

1

I have a django app, a forum app, that has templates with it. In those templates, there are urls that point to parts of the app. For instance the thread_list template has links to each thread like so:

{% for thread in threads %}
    <a href="{% url forum_thread thread %}">{{thread.title}}</a>
{% endfor %}

The thing is, I don't really like calling my urls "forum_thread". I prefer just "thread" and using the namespace feature of django. "forum_thread" may be used somewhere else in the project (namespace collision).So it will look like this:

{% for thread in threads %}
    <a href="{% url forum:thread thread %}">{{thread.title}}</a>
{% endfor %}

but this don't feel like the correct way to do this. The docs are kind of unclear here.

I want this app to be reusable and easy to configure. But I also want to use the best standards. I don't want to have the to make the user specify their own namespace name, and then have them edit every single url in each template.

How should I do urls in this app?

A: 

Have you senn URL namespaces documentation? http://docs.djangoproject.com/en/dev/topics/http/urls/#topics-http-reversing-url-namespaces

Lukasz Dziedzia