Opened 23 months ago

Closed 23 months ago

Last modified 23 months ago

#20447 closed New feature (fixed)

next_page parameter in logout function does not recognize named urls

Reported by: caumons Owned by: bmispelon
Component: contrib.auth Version: 1.5
Severity: Normal Keywords:
Cc: bmispelon@… Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

When using logout function:

logout(request[, next_page, template_name, redirect_field_name])

next_page parameter does not recognize named urls, it appends the name at the end of the current URL. E.g. if your "/" URL is named "home", then using "home" as the next_page will result in the URL /logout/home

If this won't be fixed, at least mention it in the docs. Thanks!

Change History (5)

comment:1 Changed 23 months ago by svisser

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Triage Stage changed from Unreviewed to Accepted

This seems fair.The corresponding login view does call resolve_url to lookup a variety of ways to express the URL but the logout view does not.

Either we need to make things consistent or we need to mention it in the documentation.

comment:2 Changed 23 months ago by bmispelon

  • Cc bmispelon@… added
  • Owner changed from nobody to bmispelon
  • Status changed from new to assigned
  • Type changed from Bug to New feature

The login and logout views don't actually work exactly the same way. You can't pass a next_page parameter to login (you can configure settings.LOGIN_REDIRECT_URL or pass a parameter in the request).

Still, this seems like a reasonable and useful feature, which wouldn't be hard to implement. I don't foresee any backwards-compatibility issues either.

comment:3 Changed 23 months ago by bmispelon

  • Has patch set

comment:4 Changed 23 months ago by Marc Tamlyn <marc.tamlyn@…>

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

In 980ae2ab29cb25182404eb1ccc919573edcc44f5:

Fix #20447: URL names given to contrib.auth.views are now resolved.

This commit also adds tests for the redirect feature of most auth views.
It also cleans up the tests, most notably using @override_settings instead
of ad-hoc setUp/tearDown methods.

Thanks to caumons for the report.

Conflicts:

docs/releases/1.6.txt

comment:5 Changed 23 months ago by caumons

Thanks to you for the fast fix!

I installed Django with pip command. Can I get this update into the current installed version or should I use a clone of the development version?

Thanks! :)

Last edited 23 months ago by caumons (previous) (diff)
Note: See TracTickets for help on using tickets.
Back to Top