Opened 6 years ago

Closed 2 years ago

#13749 closed New feature (fixed)

Link from admin-site to site

Reported by: Roman Kalinichenko Owned by: joelklabo
Component: contrib.admin Version: master
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)

patch.txt (1007 bytes) - added by joelklabo 6 years ago.
Patch: added link to django admin <h1> tag
ticket_13749.diff (703 bytes) - added by Sævar Öfjörð Magnússon 6 years ago.
ticket_13749.2.diff (1.5 KB) - added by DHessing 5 years ago.
Implemented julien's and adrian's suggestions
ticket_13749.3.diff (2.0 KB) - added by Niels van Dijk 5 years ago.
Updated patch. Set the 'Django administration' heading to the default/old styling.
ticket_13749.4.diff (1.9 KB) - added by DHessing 5 years ago.
removed redundant conditional test

Download all attachments as: .zip

Change History (34)

comment:1 Changed 6 years ago by Russell Keith-Magee

Component: Template systemdjango.contrib.admin
Needs documentation: unset
Needs tests: unset
Patch needs improvement: unset
Triage Stage: UnreviewedAccepted

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 '/'.

comment:2 Changed 6 years ago by joelklabo

Owner: changed from nobody to joelklabo

Changed 6 years ago by joelklabo

Attachment: patch.txt added

Patch: added link to django admin <h1> tag

comment:3 Changed 6 years ago by joelklabo

Resolution: fixed
Status: newclosed

comment:4 Changed 6 years ago by joelklabo

Resolution: fixed
Status: closedreopened

comment:5 Changed 6 years ago by joelklabo

Has patch: set

comment:6 Changed 6 years ago by Chris Beaven

Patch needs improvement: set

This should use the sites framework, and should be <h1><a>..</></h1> for valid HTML.

comment:7 Changed 6 years ago by Adrian Holovaty

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 6 years ago by Sævar Öfjörð Magnússon

Attachment: ticket_13749.diff added

comment:8 Changed 6 years ago by Sævar Öfjörð Magnússon

What about having the link in the upper right navigation? I've added a patch which does that.

comment:9 Changed 6 years ago by Julien Phalip

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 6 years ago by Julien Phalip

Severity: Normal
Type: New feature

comment:11 Changed 5 years ago by Julien Phalip

UI/UX: set

comment:12 Changed 5 years ago by DHessing

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 5 years ago by DHessing

Attachment: ticket_13749.2.diff added

Implemented julien's and adrian's suggestions

Changed 5 years ago by Niels van Dijk

Attachment: ticket_13749.3.diff added

Updated patch. Set the 'Django administration' heading to the default/old styling.

comment:13 Changed 5 years ago by Horst Gutmann <zerok@…>

Keywords: dceu2011 added
Triage Stage: AcceptedReady 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 5 years ago by Julien Phalip

Triage Stage: Ready for checkinAccepted

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 5 years ago by Julien Phalip

Patch needs improvement: set

Changed 5 years ago by DHessing

Attachment: ticket_13749.4.diff added

removed redundant conditional test

comment:16 Changed 5 years ago by DHessing

Patch needs improvement: unset

comment:17 Changed 4 years ago by Aymeric Augustin

Status: reopenednew

comment:18 Changed 3 years ago by Tim Graham <timograham@…>

In 259a6ea82cfb8bf242449666e4b643a19e54a423:

Added a link in admin branding block to admin index.

Refs #13749 and #21220.

comment:19 Changed 2 years ago by Federico Capoano

It is acceptable to link '/' or shall we provide a customizable setting to specify a different path?

Last edited 2 years ago by Federico Capoano (previous) (diff)

comment:20 Changed 2 years ago by Federico Capoano

comment:21 Changed 2 years ago by Baptiste Mispelon

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 2 years ago by Federico Capoano

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 2 years ago by Federico Capoano

Version: 1.2master

comment:24 Changed 2 years ago by johmik

Triage Stage: AcceptedReady 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 2 years ago by Claude Paroz

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 2 years ago by Baptiste Mispelon

Easy pickings: unset
Patch needs improvement: set
Triage Stage: Ready for checkinAccepted

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 2 years ago by Russell Keith-Magee

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 2 years ago by Areski Belaid

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 2 years ago by Tim Graham <timograham@…>

Resolution: fixed
Status: newclosed

In a81af7f49de7ff3f51f111de28ed3a682f67ea89:

Fixed #13749 -- Added link from admin site to front-end site.

Thanks romankrv for the suggestion.

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