Opened 19 months ago

Closed 19 months ago

Last modified 19 months ago

#21396 closed Bug (fixed)

Backwards-incompatible change in RedirectView.get_redirect_url

Reported by: aaugustin Owned by: nobody
Component: Documentation Version: 1.6
Severity: Normal Keywords:
Cc: bmispelon 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 Changed 19 months ago by bmispelon

  • Cc bmispelon added
  • Triage Stage changed from Unreviewed to Accepted

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 Changed 19 months ago by bmispelon

  • Has patch set

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

comment:3 Changed 19 months ago by timo

  • Component changed from Generic views to Documentation
  • Triage Stage changed from Accepted to Ready for checkin

comment:4 Changed 19 months ago by Baptiste Mispelon <bmispelon@…>

  • Resolution set to fixed
  • Status changed from new to closed

In f2e0266be766b0b6149377b90ae3ddc41c91c3fb:

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

Thanks to Tim for the review.

comment:5 Changed 19 months ago by Baptiste Mispelon <bmispelon@…>

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