Opened 5 years ago

Closed 10 months ago

#13749 closed New feature (fixed)

Link from admin-site to site

Reported by: romankrv Owned by: joelklabo
Component: contrib.admin Version: master
Severity: Normal Keywords: admin url dceu2011
Cc: areski 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 5 years ago.
Patch: added link to django admin <h1> tag
ticket_13749.diff (703 bytes) - added by saevarom 5 years ago.
ticket_13749.2.diff (1.5 KB) - added by DHessing 4 years ago.
Implemented julien's and adrian's suggestions
ticket_13749.3.diff (2.0 KB) - added by nvandijk 4 years ago.
Updated patch. Set the 'Django administration' heading to the default/old styling.
ticket_13749.4.diff (1.9 KB) - added by DHessing 4 years ago.
removed redundant conditional test

Download all attachments as: .zip

Change History (34)

comment:1 Changed 5 years ago by russellm

  • Component changed from Template system to django.contrib.admin
  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Triage Stage changed from Unreviewed to Accepted

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

  • Owner changed from nobody to joelklabo

Changed 5 years ago by joelklabo

Patch: added link to django admin <h1> tag

comment:3 Changed 5 years ago by joelklabo

  • Resolution set to fixed
  • Status changed from new to closed

comment:4 Changed 5 years ago by joelklabo

  • Resolution fixed deleted
  • Status changed from closed to reopened

comment:5 Changed 5 years ago by joelklabo

  • Has patch set

comment:6 Changed 5 years ago by SmileyChris

  • Patch needs improvement set

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

comment:7 Changed 5 years ago by adrian

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

comment:8 Changed 5 years ago by saevarom

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

comment:9 Changed 4 years ago by julien

  • milestone 1.3 deleted

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 4 years ago by julien

  • Severity set to Normal
  • Type set to New feature

comment:11 Changed 4 years ago by julien

  • UI/UX set

comment:12 Changed 4 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 4 years ago by DHessing

Implemented julien's and adrian's suggestions

Changed 4 years ago by nvandijk

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

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

  • Keywords dceu2011 added
  • Triage Stage changed from Accepted to 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 4 years ago by julien

  • Triage Stage changed from Ready for checkin to 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 4 years ago by julien

  • Patch needs improvement set

Changed 4 years ago by DHessing

removed redundant conditional test

comment:16 Changed 4 years ago by DHessing

  • Patch needs improvement unset

comment:17 Changed 2 years ago by aaugustin

  • Status changed from reopened to new

comment:18 Changed 21 months ago by Tim Graham <timograham@…>

In 259a6ea82cfb8bf242449666e4b643a19e54a423:

Added a link in admin branding block to admin index.

Refs #13749 and #21220.

comment:19 Changed 13 months ago by nemesisdesign

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

Last edited 13 months ago by nemesisdesign (previous) (diff)

comment:20 Changed 13 months ago by nemesisdesign

comment:21 Changed 13 months ago by bmispelon

  • 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 13 months ago by nemesisdesign

  • 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 13 months ago by nemesisdesign

  • Version changed from 1.2 to master

comment:24 Changed 11 months ago by johmik

  • Triage Stage changed from Accepted to 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 11 months ago by claudep

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 11 months ago by bmispelon

  • Easy pickings unset
  • Patch needs improvement set
  • Triage Stage changed from Ready for checkin to 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 11 months ago by russellm

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 11 months ago by areski

  • Cc areski added

Here a PR that follow bmispelon suggestions: https://github.com/django/django/pull/3103
Comments will be welcome!

comment:29 Changed 10 months ago by Tim Graham <timograham@…>

  • Resolution set to fixed
  • Status changed from new to closed

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