Opened 5 years ago

Closed 5 years ago

Last modified 5 years ago

#25907 closed New feature (wontfix)

Alternative Way of Specifying URL Patterns

Reported by: Sven R. Kunze Owned by: nobody
Component: Core (URLs) Version: master
Severity: Normal Keywords:
Cc: tzanke@… Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no


Other frameworks (like MVC 5) provide an inline-way of specifying the URL pattern for a view.

Would it be possible to introduce such thing for Django?

Internally, we are working on something like this in order to accelerate development and maintenance for our production system.

Manually looking up URLs in the and then jump to the actual view class is quite error-prone and tedious.

Internally, we evaluate two alternatives:

1) via class attribute: url
2) via decorator on class

# alternative 1
class ThingView(DetailView):
    url = '/thing(?P<pk>\d+)'
    template_name = 'thing.html'

# alternative 2
class ThingView(DetailView):
    template_name = 'thing.html'

Change History (2)

comment:1 Changed 5 years ago by Tim Graham

Resolution: wontfix
Status: newclosed

You could propose it on the DevelopersMailingList (I couldn't find a past discussion from a quick seach), but I doubt we'd want to add another way of defining URLs. If you really want this in your own projects, you could possibly write an implantation that lives in each app's file and "autodiscovers" the URLs defined by your views according to whatever convention you want to use.

comment:2 Changed 5 years ago by TZanke

Cc: tzanke@… added
Note: See TracTickets for help on using tickets.
Back to Top