#15552 closed New feature (fixed)
LOGIN_URL should allow named urls
Reported by: | Wolph | Owned by: | nobody |
---|---|---|---|
Component: | contrib.auth | Version: | 1.2 |
Severity: | Normal | Keywords: | login_url logout_url login_redirect_url named_url url_tag dceu2011 |
Cc: | gezuru@… | Triage Stage: | Accepted |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
To adhere to the DRY principle it seems quite silly that one has to hardcode the LOGIN_URL
, LOGOUT_URL
and LOGIN_REDIRECT_URL
.
It would be logical to simply use a named url so it always redirects to the login view you specified, regardless of the SCRIPT_NAME
and your url configs.
Attachments (1)
Change History (16)
comment:1 by , 14 years ago
Triage Stage: | Unreviewed → Accepted |
---|
comment:2 by , 14 years ago
Type: | → New feature |
---|
comment:3 by , 14 years ago
Severity: | → Normal |
---|
by , 13 years ago
Attachment: | t15552.patch added |
---|
comment:4 by , 13 years ago
Easy pickings: | unset |
---|---|
Has patch: | set |
UI/UX: | unset |
I've added a patch that implements Alex Gaynor's suggestion from the thread mentioned above and basically applies the logic from redirect() to LOGIN_URL and LOGIN_REDIRECT_URL
comment:5 by , 13 years ago
Keywords: | dceu2011 added |
---|
comment:6 by , 13 years ago
Triage Stage: | Accepted → Ready for checkin |
---|
comment:7 by , 13 years ago
Patch needs improvement: | set |
---|
The resolve_url
function fits better in the django.shortcuts
module instead of a new django.utils.urls
module.
comment:8 by , 13 years ago
Triage Stage: | Ready for checkin → Accepted |
---|
comment:9 by , 13 years ago
I placed it in utils because I wasn't sure you'd want resolve_url as part of the "public" shortcuts module.
But if that is ok I'll update the patch.
comment:11 by , 12 years ago
Patch needs improvement: | unset |
---|
I've updated this patch for 1.5 trunk as of today and have submitted a pull request on GitHub https://github.com/django/django/pull/343
comment:12 by , 12 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
comment:14 by , 12 years ago
The current implementation does not allow named url arguments, right?
I'm using django-social-auth and would like to point LOGIN_URL
to resolve('socialauth_begin', args=('google-oauth2',))
.
comment:15 by , 12 years ago
Cc: | added |
---|
I think this is a valid point, and the proposed solution is the right one. See also discussion at http://groups.google.com/group/django-developers/browse_frm/thread/fa3661888716f940/8b4d0cf8f34e5493
Also refs #8906.