Opened 15 years ago
Closed 14 years ago
#6470 closed (fixed)
Admin urls should use urlpatterns
Reported by: | jdetaeye | Owned by: | Alex Gaynor |
---|---|---|---|
Component: | contrib.admin | Version: | dev |
Severity: | Keywords: | nfa-someday | |
Cc: | schlaber@…, jay.wineinger@…, carl@…, ross@… | Triage Stage: | Accepted |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
If your model has a string as key, there are some admin change pages that are not accessible.
If the primary key of your object ends in "add", "history" or "delete", you can't access the change form any more.
Culprit is the following code in admin\options.py, responsible for parsing the URL:
if url is None: return self.changelist_view(request) elif url.endswith('add'): return self.add_view(request) elif url.endswith('history'): return self.history_view(request, unquote(url[:-8])) elif url.endswith('delete'): return self.delete_view(request, unquote(url[:-7])) else: return self.change_view(request, unquote(url))
A corrected version is:
if url is None: return self.changelist_view(request) elif url == 'add': return self.add_view(request) elif url.endswith('/history'): return self.history_view(request, unquote(url[:-8])) elif url.endswith('/delete'): return self.delete_view(request, unquote(url[:-7])) else: return self.change_view(request, unquote(url))
This applies also to the current admin, but in the current only an object with a key equal to "add" will not be accessible (since the url processing is better).
Attachments (9)
Change History (25)
comment:1 Changed 15 years ago by
Triage Stage: | Unreviewed → Accepted |
---|
comment:2 Changed 15 years ago by
Keywords: | nfa-blocker added |
---|
Changed 15 years ago by
Attachment: | nfa-options.diff added |
---|
comment:3 Changed 15 years ago by
Summary: | Admin URLs are not adequately examined → Admin urls should use urlpatterns |
---|
The fix for this ticket is waiting for some changes to the way url dispatch works. There isn't currently a way for the AdminSite
class to supply urlpatterns.
comment:4 Changed 15 years ago by
Keywords: | nfa-someday added; nfa-blocker removed |
---|
This won't(and doesn't need to) happen pre-merge.
Changed 15 years ago by
Attachment: | nfa-urls.diff added |
---|
Initial work on implementing them using a property, not complete(although more or less functional), tests do not all pass
comment:5 Changed 15 years ago by
Version: | newforms-admin → SVN |
---|
Changed 15 years ago by
Attachment: | admin-urlpatterns-6470.diff added |
---|
An update to the patch to apply cleanly to r8129
comment:6 Changed 15 years ago by
Cc: | schlaber@… added |
---|
comment:7 Changed 15 years ago by
Cc: | jay.wineinger@… added |
---|
comment:8 Changed 15 years ago by
Cc: | carl@… added |
---|
Changed 14 years ago by
Attachment: | admin-urlpatterns-6470.2.diff added |
---|
Latest version, full tests pass, and should be backwards compatible, updated docs
comment:9 Changed 14 years ago by
Owner: | changed from nobody to Alex Gaynor |
---|
comment:10 Changed 14 years ago by
Has patch: | set |
---|
comment:11 Changed 14 years ago by
Just saw malcolm's comment on the 1.1 features list(about how multiple AdminSite instances will cause a probelm), and I'm 100% in agreement that that is an issue, however it's not an issue specific to my proposed method for handling this, you need to have a distinct name for each admin site's url, as such the admin site itself needs to have some concept of it's own name.
comment:12 Changed 14 years ago by
Cc: | ross@… added |
---|
Changed 14 years ago by
Attachment: | admin-urlpatterns.2.diff added |
---|
small update to always use raw strings
comment:13 Changed 14 years ago by
Changed 14 years ago by
Attachment: | admin-urlpatterns.3.diff added |
---|
Changed 14 years ago by
Attachment: | admin-urlpatterns.4.diff added |
---|
Changed 14 years ago by
Attachment: | admin-urlpatterns.5.diff added |
---|
comment:14 Changed 14 years ago by
Resolution: | → fixed |
---|---|
Status: | new → closed |
(In [9739]) Fixed #6470: made the admin use a URL resolver.
This *is* backwards compatible, but admin.site.root()
has been deprecated. The new style is ('^admin/', include(admin.site.urls))
; users will need to update their code to take advantage of the new customizable admin URLs.
Thanks to Alex Gaynor.
comment:15 Changed 14 years ago by
Resolution: | fixed |
---|---|
Status: | closed → reopened |
There is a typo in contrib/admin/sites.py [9739], isn't it?
@@ -199,7 +199,7 @@ name='%sadmin_index' % self.name), url(r'^logout/$', wrap(self.logout), - name='%sadmin_logout'), + name='%sadmin_logout' % self.name), url(r'^password_change/$', wrap(self.password_change), name='%sadmin_password_change' % self.name),
comment:16 Changed 14 years ago by
Resolution: | → fixed |
---|---|
Status: | reopened → closed |
There is a separate ticket for this error.
Agreed. This should be fixed.