#21396 closed Bug (fixed)
Backwards-incompatible change in RedirectView.get_redirect_url
Reported by: | Aymeric Augustin | Owned by: | nobody |
---|---|---|---|
Component: | Documentation | Version: | 1.6 |
Severity: | Normal | Keywords: | |
Cc: | Baptiste Mispelon | Triage Stage: | Ready for checkin |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
[b7bd7087] (for #15273) changes the signature of RedirectView.get_redirect_url
. The documented signature is RedirectView.get_redirect_url(self, **kwargs)
.
In Django 1.5 that was correct; in Django 1.6, unnamed URL captures are passed as positional arguments.
We should at least fix the documentation and mention the backwards incompatibility in the release notes.
Change History (5)
comment:1 by , 11 years ago
Cc: | added |
---|---|
Triage Stage: | Unreviewed → Accepted |
comment:2 by , 11 years ago
Has patch: | set |
---|
I made a PR for the documentation issue: https://github.com/django/django/pull/1889
comment:3 by , 11 years ago
Component: | Generic views → Documentation |
---|---|
Triage Stage: | Accepted → Ready for checkin |
comment:4 by , 11 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
Note:
See TracTickets
for help on using tickets.
The documentation of
get_redirect_url
[1] should be amended to reflect the new signature (self, *args, **kwargs
) and also to describe the usage of the newpattern_name
attribute.There is indeed a problem if someone has extended
RedirectView
and definedget_redirect_url
only taking**kwargs
as arguments (as is documented).If that view is used on a urlpattern that has unnamed capture groups, a
TypeError
will be thrown.We might be able to restore backwards-compatibility with some introspection on the method's signature (
inspect.getargspect
) or maybe with sometry/except
statements inRedirectView.get
.[1] https://docs.djangoproject.com/en/1.6/ref/class-based-views/base/#django.views.generic.base.RedirectView.get_redirect_url