Opened 18 years ago
Closed 17 years ago
#3491 closed (fixed)
[newforms-admin] Admin templates use relative links rather than url tag
Reported by: | Owned by: | nobody | |
---|---|---|---|
Component: | contrib.admin | Version: | dev |
Severity: | Keywords: | ||
Cc: | dev@… | Triage Stage: | Ready for checkin |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | yes |
Easy pickings: | no | UI/UX: | no |
Description
When I follow the example from the section "Custom admin views" in the djangobook chapter 18, I notice that the links in the upper right of the admin ie: "documentation", "change password", and "log out" no longer function correctly. For example, when viewing the page "admin/bookstore/report" the links in the upper right point to "admin/bookstore/report/doc" instead of "admin/doc". The Logout link points to "admin/bookstore/report/logout" instead of "admin/logout". Clicking the links results in a 404 Not Found error.
Attachments (1)
Change History (16)
comment:1 by , 18 years ago
Triage Stage: | Unreviewed → Accepted |
---|
comment:2 by , 18 years ago
Resolution: | → invalid |
---|---|
Status: | new → closed |
comment:3 by , 18 years ago
It seems to me that althought this bug was dicovered while using the Django Book, the bug is actually in the django admin code. The problem is that the django admin templates are using hard coded relative html hyperlinks instead of using the template function {%url%}. The admin templates need to be updated to use this template function. That would fix the problem.
comment:4 by , 18 years ago
Resolution: | invalid |
---|---|
Status: | closed → reopened |
Summary: | Djangobook error in Chapter 18 section "custom admin views" → Admin templates use relative links rather than url tag |
Sorry, my bad.
comment:5 by , 18 years ago
Hmm.. I'm unable to recreate this bug, I've tried a custom change_form and a reworking of the example in the book (using a model I already had). However, looking at the templates, they're all relative, so I would expect there to be issues. Can you give me some more info about the views/templates you're using?
comment:6 by , 18 years ago
Cc: | added |
---|
comment:7 by , 18 years ago
I do not have the templates here in front of me right now, but the problem seems to come when I create admin pages more than one level down in the url path. This breaks the relative URLs.
for instance, a custom page at http://mysite.com/admin/additional_function works fine
but a custom page at http://mysite.com/admin/extra_path/additional_function does _not_ work correctly.
comment:8 by , 18 years ago
I tried changing the hardcoded paths like <a href="logout/">{% trans 'Log out' %}</a> to use the url template function like <a href="{% url django.contrib.auth.views.logout %}">{% trans 'Log out' %}</a> but get an error that the view cannot be found. Not sure why.
comment:9 by , 18 years ago
Has patch: | set |
---|
I have a patch that fixes the problem. I cannot attach it tough. Trac tell me that it is spam. Please contact me if you would like the patch.
comment:10 by , 18 years ago
Patch needs improvement: | set |
---|
Hi saintsjd, can you paste it at dpaste and link to that here (make sure you click the "hold" tag).
comment:13 by , 18 years ago
Summary: | Admin templates use relative links rather than url tag → [newforms-admin] Admin templates use relative links rather than url tag |
---|
Things in dpaste aren't "ready to checkin", because they will disappear if not accessed periodically. Please copy them over to here if they are to be preserved.
comment:14 by , 18 years ago
Hmm sorry - there's not much else to do though if the Trac won't take it. I was going to paste it into a comment here, but I got distracted & forgot.
comment:15 by , 17 years ago
Resolution: | → fixed |
---|---|
Status: | reopened → closed |
This tracker is for Django itself; the book isn't tracked here. Please send an email to feedback@… instead.