[Django] #25907: Alternative Way of Specifying URL Patterns

8 views
Skip to first unread message

Django

unread,
Dec 10, 2015, 7:07:12 AM12/10/15
to django-...@googlegroups.com
#25907: Alternative Way of Specifying URL Patterns
-----------------------------+--------------------
Reporter: srkunze | Owner: nobody
Type: New feature | Status: new
Component: Core (URLs) | Version: master
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Easy pickings: 0 | UI/UX: 0
-----------------------------+--------------------
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 url.py 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
@url('/thing/(?P<pk>\d+)'):
class ThingView(DetailView):
template_name = 'thing.html'
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/25907>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Dec 10, 2015, 8:28:06 AM12/10/15
to django-...@googlegroups.com
#25907: Alternative Way of Specifying URL Patterns
-----------------------------+--------------------------------------
Reporter: srkunze | Owner: nobody
Type: New feature | Status: closed

Component: Core (URLs) | Version: master
Severity: Normal | Resolution: wontfix
Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-----------------------------+--------------------------------------
Changes (by timgraham):

* status: new => closed
* needs_better_patch: => 0
* resolution: => wontfix
* needs_tests: => 0
* needs_docs: => 0


Comment:

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 `urls.py` file and
"autodiscovers" the URLs defined by your views according to whatever
convention you want to use.

--
Ticket URL: <https://code.djangoproject.com/ticket/25907#comment:1>

Django

unread,
Jan 28, 2016, 3:11:40 AM1/28/16
to django-...@googlegroups.com
#25907: Alternative Way of Specifying URL Patterns
-----------------------------+--------------------------------------
Reporter: srkunze | Owner: nobody
Type: New feature | Status: closed

Component: Core (URLs) | Version: master
Severity: Normal | Resolution: wontfix
Keywords: | Triage Stage: Unreviewed

Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-----------------------------+--------------------------------------
Changes (by TZanke):

* cc: tzanke@… (added)


--
Ticket URL: <https://code.djangoproject.com/ticket/25907#comment:2>

Reply all
Reply to author
Forward
0 new messages