Opened 16 years ago

Closed 16 years ago

#10268 closed (invalid)

Restricting named URL patterns to app

Reported by: rihad Owned by: nobody
Component: Uncategorized Version: dev
Severity: Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description (last modified by Karen Tracey)

When you name your URL patterns, make sure you use names that are unlikely to clash with any other application's choice of names. If you call your URL pattern comment, and another application does the same thing, there's no guarantee which URL will be inserted into your template when you use this name.

Putting a prefix on your URL names, perhaps derived from the application name, will decrease the chances of collision. We recommend something like myapp-comment instead of comment.

Taken from here: http://docs.djangoproject.com/en/dev/topics/http/urls/

I'm sure Django knows in the context of which app it's currently operating, so can't it deduce the app-specific prefix that would make the name unique across the project (like the app name) itself? For example in Symfony web-framework routing labels (aka named URL patterns) are app, not project, specific.

Change History (1)

comment:1 by Karen Tracey, 16 years ago

Description: modified (diff)
Resolution: invalid
Status: newclosed

[Fixed formatting. (Please use preview, also {{{ }}} is for preformatted text, not quoting, so I italicized the quote from the doc instead of just fixing the {{{ }}} placement, since with the triple curly brackets you just got a long quote that you had to scroll right to read.)]

This proposal does not have enough specifics to be a viable ticket. You say you are sure Django knows the context of which app is currently running, but that is not true. When servicing a request, code from many apps may be called. When rendering a template, code from many apps may be called. The only things strongly tied to an app in Django are models, and perhaps (given how django.contrib.admin.autodiscover() operates) admin definitions.

There is no notion of a "current app" when url patterns are being evaluated, nor when a template is rendered. So it isn't at all clear to me how you expect Django to auto-determine an appropriately unique app-specific prefix for named url patterns, neither when they are evaluated/named nor when they are referenced via {% url %} tags. Without such specifics, I don't see how this ticket is going to make any progress, so for now at least I'm closing it as invalid.

Note: See TracTickets for help on using tickets.
Back to Top