Opened 11 years ago

Closed 11 years ago

Last modified 11 years ago

#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 Baptiste Mispelon, 11 years ago

Cc: Baptiste Mispelon added
Triage Stage: UnreviewedAccepted

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 new pattern_name attribute.

There is indeed a problem if someone has extended RedirectView and defined get_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 some try/except statements in RedirectView.get.

[1] https://docs.djangoproject.com/en/1.6/ref/class-based-views/base/#django.views.generic.base.RedirectView.get_redirect_url

comment:2 by Baptiste Mispelon, 11 years ago

Has patch: set

I made a PR for the documentation issue: https://github.com/django/django/pull/1889

comment:3 by Tim Graham, 11 years ago

Component: Generic viewsDocumentation
Triage Stage: AcceptedReady for checkin

comment:4 by Baptiste Mispelon <bmispelon@…>, 11 years ago

Resolution: fixed
Status: newclosed

In f2e0266be766b0b6149377b90ae3ddc41c91c3fb:

Fixed #21396: Document backwards-incompatible change in RedirectView.get_redirect_url.

Thanks to Tim for the review.

comment:5 by Baptiste Mispelon <bmispelon@…>, 11 years ago

In 6c34e18bd41237328b50177411809bd800fcab21:

[1.6.x] Fixed #21396: Document backwards-incompatible change in RedirectView.get_redirect_url.

Thanks to Tim for the review.

Backport of f2e0266be766b0b6149377b90ae3ddc41c91c3fb from master.

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