named urls should begin with a unique common prefix

Bug #996640 reported by Richard Wackerbarth
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Postorius
Confirmed
Undecided
pjoshi

Bug Description

By Django common practice, in most cases, URL names should be distinct within a flat namespace.

This avoids naming conflicts and leaves the Django Namespace mechanism available for other uses.

I recommend starting each URL name with "mm_", rather than "domain_index" use "mm_domain_index", etc.

Revision history for this message
Florian Fuchs (flo-fuchs) wrote :

This should clearly go into the next release, so we avoid any url pattern collisions with other apps.

However, I tend to think that the Django namespace mechanism for view names might be the better solution. We cannot rule out that someone else might use the 'mm_' prefix for view_names, but Django's namespace mechanism can.

Why is it not a good idea to use the Django mechanism?

Changed in postorius:
milestone: none → 1.0.0a2
status: New → Confirmed
Revision history for this message
pjoshi (prakhar126) wrote :

We have to add "mm" prefix to every url like if the list show view is on url "/postorius/lists" should be shown on
"/mm/postorius/lists" , right ?

Changed in postorius:
assignee: nobody → pjoshi (prakhar126)
Revision history for this message
pjoshi (prakhar126) wrote :

let me correct it again, we want the urls like "/potorius/lists" to be changed to "mm_postorius/lists" . This is what required to resolve that issue ?

Revision history for this message
Richard Wackerbarth (wacky) wrote :

@pjoshi - No, it is not the URL itself to which I refer. It is the "name" parameter of the url() function which allows a url pattern to be referenced within Django.

As an example, an app might have a detail view which is referenced by
    url(r'^(?P<pk>[0-9]+)/$', views.DetailView.as_view(), name='detail'),

From any page within the website, I can reference that view in a manner independent of actual URL by using
  <a href="{% url 'detail' %}"> ... </a>

Now, I might write another app which also has a detail view.
If it also has a similar entry, where the name assigned to the URL is "detail", then the reference would be ambiguous.
Namespacing allow me to differentiate between these two by referencing the namespace such as "{% url 'myapp:detail' %}

However, another use of namespace is to allow the same cluster of pages to appear in multiple places within the website.

Thus, by avoiding the generic name (such as 'detail') and relying on namespace to distinguish between apps, using an application specific name 'mm_detail' leaves the namespace mechanism free for other purposes. (Such as having multiple instances within the same website.

My use case is youth sports organization whose website is a combination of different sports. To the visitor, it generally appears that each sport is a separate website. The mailing list subscription pages thus appear multiple times. The namespace mechanism is used to distinguish between these instances.

Revision history for this message
pjoshi (prakhar126) wrote :

@Richard So basically you need to create urls such that we will "mm_details" as the name of the url but url will remain same and this will be helpful to didtingwish between urls of some other app which may also contain "details" as a url name, right ?

Revision history for this message
Richard Wackerbarth (wacky) wrote : Re: [Bug 996640] named urls should begin with a unique common prefix

Correct.

> On Apr 14, 2015, at 10:06 AM, pjoshi <email address hidden> wrote:
>
> @Richard So basically you need to create urls such that we will
> "mm_details" as the name of the url but url will remain same and this
> will be helpful to didtingwish between urls of some other app which may
> also contain "details" as a url name, right ?

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.