Opened 14 years ago
Closed 12 years ago
#15273 closed New feature (fixed)
Extend RedirectView to allow named-URL reversal?
Reported by: | Simon Meers | Owned by: | nobody |
---|---|---|---|
Component: | Generic views | Version: | dev |
Severity: | Normal | Keywords: | |
Cc: | Triage Stage: | Unreviewed | |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | yes | UI/UX: | no |
Description
It would be nice to allow named-URL reversal in the new RedirectView
.
Example workaround:
class NamedRedirectView(RedirectView): url_name = None def get_redirect_url(**kwargs): if self.url_name: return reverse(url_name) return super(NamedRedirectView, self).get_redirect_url(**kwargs)
url(r'^blah/', NamedRedirectView.as_view(url_name='xyz:abc')),
I would imagine it is fairly common to want to keep URLconfs DRY, so perhaps this should be built into RedirectView
as an additional option? Of course reversing with args/kwargs is a different story altogether...
Change History (5)
comment:1 by , 14 years ago
Triage Stage: | Unreviewed → Design decision needed |
---|
comment:2 by , 14 years ago
Severity: | → Normal |
---|---|
Type: | → New feature |
comment:3 by , 14 years ago
Easy pickings: | set |
---|---|
Resolution: | → fixed |
Status: | new → closed |
I believe this is solved by https://docs.djangoproject.com/en/dev/topics/http/urls/#reverse-lazy in [16121]
comment:4 by , 12 years ago
Has patch: | set |
---|---|
Resolution: | fixed |
Status: | closed → new |
Triage Stage: | Design decision needed → Unreviewed |
UI/UX: | unset |
This has a pull request: https://github.com/django/django/pull/568
comment:5 by , 12 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
Note:
See TracTickets
for help on using tickets.
Agreed that it should be easier to do a named URL redirect. The same is true of success URLs on edit views. Whatever solution we come up with should be consistent across all uses if at all possible.