Opened 18 years ago

Closed 17 years ago

#3491 closed (fixed)

[newforms-admin] Admin templates use relative links rather than url tag

Reported by: saintsjd@… 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)

admin-patch.diff (1.3 KB ) - added by Malcolm Tredinnick 18 years ago.
Copy of upload to dpaste

Download all attachments as: .zip

Change History (16)

comment:1 by Simon G. <dev@…>, 18 years ago

Triage Stage: UnreviewedAccepted

comment:2 by frankie@…, 18 years ago

Resolution: invalid
Status: newclosed

This tracker is for Django itself; the book isn't tracked here. Please send an email to feedback@… instead.

comment:3 by saintsjd@…, 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 frankie@…, 18 years ago

Resolution: invalid
Status: closedreopened
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 Simon G. <dev@…>, 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 Simon G. <dev@…>, 18 years ago

Cc: dev@… added

comment:7 by saintsjd@…, 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 anonymous, 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 saintsjd@…, 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 Simon G. <dev@…>, 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:11 by saintsjd@…, 18 years ago

dpaste... I should have thought of that. Here is the patch

http://dpaste.com/hold/9747/

comment:12 by Simon G. <dev@…>, 18 years ago

Triage Stage: AcceptedReady for checkin

Thanks.

by Malcolm Tredinnick, 18 years ago

Attachment: admin-patch.diff added

Copy of upload to dpaste

comment:13 by Malcolm Tredinnick, 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 Simon G. <dev@…>, 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 Gary Wilson, 17 years ago

Resolution: fixed
Status: reopenedclosed

(In [6391]) Fixed #3491 -- Fixed links in user-tools section of admin's base.html template to use the url template tag. This also removes the need for child templates to override the block just to adjust the relative path. Thanks, saintsjd@….

Note: See TracTickets for help on using tickets.
Back to Top