Opened 15 years ago
Closed 10 years ago
#13749 closed New feature (fixed)
Link from admin-site to site
Reported by: | Roman Kalinichenko | Owned by: | joelklabo |
---|---|---|---|
Component: | contrib.admin | Version: | dev |
Severity: | Normal | Keywords: | admin url dceu2011 |
Cc: | Areski Belaid | Triage Stage: | Accepted |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | yes |
Easy pickings: | no | UI/UX: | yes |
Description
Somtimes one useful have feature like: link on top header which go to site.
Attachments (5)
Change History (34)
comment:1 by , 15 years ago
Component: | Template system → django.contrib.admin |
---|---|
Triage Stage: | Unreviewed → Accepted |
comment:2 by , 14 years ago
Owner: | changed from | to
---|
comment:3 by , 14 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
comment:4 by , 14 years ago
Resolution: | fixed |
---|---|
Status: | closed → reopened |
comment:5 by , 14 years ago
Has patch: | set |
---|
comment:6 by , 14 years ago
Patch needs improvement: | set |
---|
This should use the sites framework, and should be <h1><a>..</></h1> for valid HTML.
comment:7 by , 14 years ago
I like the idea of linking to the "real" site from the admin site by default, but the "Django administration" text shouldn't be the link. If anything, "Django administration" should link to the main index page of the *admin* site. I'd be in favor of adding a smaller "View live site" link next to the "Django administration" header. Although it might technically be incorrect to link this to "/" in some case, I think that's the common case (a reasonable default), and it would be easy enough to change.
If somebody provides a patch that does what I've described above, and it looks good from a design standpoint, I'll check it in.
by , 14 years ago
Attachment: | ticket_13749.diff added |
---|
comment:8 by , 14 years ago
What about having the link in the upper right navigation? I've added a patch which does that.
comment:9 by , 14 years ago
milestone: | 1.3 |
---|
This is technically a new feature and there is no definite patch for it yet, so I'm moving out of 1.3 which is launching really soon. I think more discussion needs to happen here. I too feel the need of having that link available in most projects, but not all. Even if that's a sensible default, a good patch would allow to override it easily, probably via a {% block %}
.
I'm also not convinced that "live site" is the right term as it can be ambiguous (the admin itself could be considered live when it's deployed to the server). So I'd prefer something along the lines of "Site's front end" (or something prettier) as opposed to the admin which is the site's back end.
comment:10 by , 14 years ago
Severity: | → Normal |
---|---|
Type: | → New feature |
comment:11 by , 14 years ago
UI/UX: | set |
---|
comment:12 by , 14 years ago
Easy pickings: | unset |
---|---|
Patch needs improvement: | unset |
I chose to use 'view site' as the link text, so it looks like the 'view on site' text that's available on models on the admin site. Do I need to do anything special about this new translation string? Also I'm not sure what the {{ root_path }} thing is supposed to do, I just copied/pasted it from base.html. It looked like some default fallback that's used everywhere.
I also implemented the link to the main page (as per adrian), as it is a convention on most websites.
by , 14 years ago
Attachment: | ticket_13749.2.diff added |
---|
Implemented julien's and adrian's suggestions
by , 14 years ago
Attachment: | ticket_13749.3.diff added |
---|
Updated patch. Set the 'Django administration' heading to the default/old styling.
comment:13 by , 14 years ago
Keywords: | dceu2011 added |
---|---|
Triage Stage: | Accepted → Ready for checkin |
The patch looks fine to me. Personally some kind of integration with the sites-framework would be nice, but it would add a usually unnecessary dependency and could also be done by people who customize the admin templates.
comment:14 by , 14 years ago
Triage Stage: | Ready for checkin → Accepted |
---|
This is looking good. However, {% url 'admin:index' %}
should always return a url, so the conditional test and the use of root_path
are redundant. The template code could be simplified to:
<h1 id="site-name"><a href="{% url 'admin:index' %}">{% trans 'Django administration' %}</a></h1>
Note that root_path
should eventually be made completely redundant by #15294.
comment:15 by , 14 years ago
Patch needs improvement: | set |
---|
comment:16 by , 14 years ago
Patch needs improvement: | unset |
---|
comment:17 by , 12 years ago
Status: | reopened → new |
---|
comment:19 by , 11 years ago
It is acceptable to link '/' or shall we provide a customizable setting to specify a different path?
comment:20 by , 11 years ago
pull request opened on github: https://github.com/django/django/pull/2809/files
comment:21 by , 11 years ago
Needs documentation: | set |
---|---|
Needs tests: | set |
Patch needs improvement: | set |
Hi!
Patch looks good but it needs documentation (a mention in the release notes) and some tests.
Thanks!
comment:22 by , 11 years ago
Easy pickings: | set |
---|---|
Needs documentation: | unset |
Needs tests: | unset |
Patch needs improvement: | unset |
Hi Baptiste,
I added a line in the release notes (1.8) and added one test for the "View site" string.
comment:23 by , 11 years ago
Version: | 1.2 → master |
---|
comment:24 by , 10 years ago
Triage Stage: | Accepted → Ready for checkin |
---|
Ran tests with PYTHONPATH=.. python runtests.py --settings=test_sqlite admin_views
Looks ok
What about the translations for this new field? Do the translators get informed about it automatically (is there a 'list' functionality for untranslated fields?), or should I write a new ticket for this?
comment:25 by , 10 years ago
No need for a ticket, if the string is marked for translation (with trans
), the traditional translation workflow will take care of it.
comment:26 by , 10 years ago
Easy pickings: | unset |
---|---|
Patch needs improvement: | set |
Triage Stage: | Ready for checkin → Accepted |
Hi,
I've had a chance to discuss this with a few people at EuroPython and we came to the conclusion that another approach is needed.
Create a new attribute on Adminsite
(maybe call it site_url
, similar to site_header
, site_title
, etc) which would default to '/' and use this in the template.
Users could customize this link to be what matches their setup (but the default should be good enough for the general case) and even disable it if they want (the template should check if this attribute is set and not show any link if that's not the case).
I'll remove the easy pickings
flag because it might be a bit more complicated to implement it this way.
Thanks
comment:27 by , 10 years ago
It shouldn't be *that* complicated - it should just be an attribute on AdminSite that returns reverse('%s:index" % self.name). The ability to have multiple installations of admin was one of the design requirements for namespaced URLs when we added them.
comment:28 by , 10 years ago
Cc: | added |
---|
Here a PR that follow bmispelon suggestions: https://github.com/django/django/pull/3103
Comments will be welcome!
comment:29 by , 10 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
Agreed; When I modify the base template for a site to say "Myproject admin" instead of "Django Admin", I usually make that text a link to '/'.