Opened 13 years ago
Closed 9 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 Changed 13 years ago by
Component: | Template system → django.contrib.admin |
---|---|
Triage Stage: | Unreviewed → Accepted |
comment:2 Changed 13 years ago by
Owner: | changed from nobody to joelklabo |
---|
comment:3 Changed 13 years ago by
Resolution: | → fixed |
---|---|
Status: | new → closed |
comment:4 Changed 13 years ago by
Resolution: | fixed |
---|---|
Status: | closed → reopened |
comment:5 Changed 13 years ago by
Has patch: | set |
---|
comment:6 Changed 13 years ago by
Patch needs improvement: | set |
---|
This should use the sites framework, and should be <h1><a>..</></h1> for valid HTML.
comment:7 Changed 13 years ago by
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.
Changed 13 years ago by
Attachment: | ticket_13749.diff added |
---|
comment:8 Changed 13 years ago by
What about having the link in the upper right navigation? I've added a patch which does that.
comment:9 Changed 13 years ago by
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 Changed 13 years ago by
Severity: | → Normal |
---|---|
Type: | → New feature |
comment:11 Changed 12 years ago by
UI/UX: | set |
---|
comment:12 Changed 12 years ago by
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.
Changed 12 years ago by
Attachment: | ticket_13749.2.diff added |
---|
Implemented julien's and adrian's suggestions
Changed 12 years ago by
Attachment: | ticket_13749.3.diff added |
---|
Updated patch. Set the 'Django administration' heading to the default/old styling.
comment:13 Changed 12 years ago by
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 Changed 12 years ago by
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 Changed 12 years ago by
Patch needs improvement: | set |
---|
comment:16 Changed 12 years ago by
Patch needs improvement: | unset |
---|
comment:17 Changed 11 years ago by
Status: | reopened → new |
---|
comment:19 Changed 9 years ago by
It is acceptable to link '/' or shall we provide a customizable setting to specify a different path?
comment:20 Changed 9 years ago by
pull request opened on github: https://github.com/django/django/pull/2809/files
comment:21 Changed 9 years ago by
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 Changed 9 years ago by
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 Changed 9 years ago by
Version: | 1.2 → master |
---|
comment:24 Changed 9 years ago by
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 Changed 9 years ago by
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 Changed 9 years ago by
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 Changed 9 years ago by
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 Changed 9 years ago by
Cc: | Areski Belaid added |
---|
Here a PR that follow bmispelon suggestions: https://github.com/django/django/pull/3103
Comments will be welcome!
comment:29 Changed 9 years ago by
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 '/'.