Opened 14 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)

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

Download all attachments as: .zip

Change History (34)

comment:1 by Russell Keith-Magee, 14 years ago

Component: Template systemdjango.contrib.admin
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 by joelklabo, 14 years ago

Owner: changed from nobody to joelklabo

by joelklabo, 14 years ago

Attachment: patch.txt added

Patch: added link to django admin <h1> tag

comment:3 by joelklabo, 14 years ago

Resolution: fixed
Status: newclosed

comment:4 by joelklabo, 14 years ago

Resolution: fixed
Status: closedreopened

comment:5 by joelklabo, 14 years ago

Has patch: set

comment:6 by Chris Beaven, 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 Adrian Holovaty, 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 Sævar Öfjörð Magnússon, 14 years ago

Attachment: ticket_13749.diff added

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

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

comment:9 by Julien Phalip, 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 Julien Phalip, 14 years ago

Severity: Normal
Type: New feature

comment:11 by Julien Phalip, 13 years ago

UI/UX: set

comment:12 by DHessing, 13 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 DHessing, 13 years ago

Attachment: ticket_13749.2.diff added

Implemented julien's and adrian's suggestions

by Niels van Dijk, 13 years ago

Attachment: ticket_13749.3.diff added

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

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

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

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

Patch needs improvement: set

by DHessing, 13 years ago

Attachment: ticket_13749.4.diff added

removed redundant conditional test

comment:16 by DHessing, 13 years ago

Patch needs improvement: unset

comment:17 by Aymeric Augustin, 12 years ago

Status: reopenednew

comment:18 by Tim Graham <timograham@…>, 11 years ago

In 259a6ea82cfb8bf242449666e4b643a19e54a423:

Added a link in admin branding block to admin index.

Refs #13749 and #21220.

comment:19 by Federico Capoano, 10 years ago

So I guess this ticket can be closed, right?

Version 0, edited 10 years ago by Federico Capoano (next)

comment:20 by Federico Capoano, 10 years ago

comment:21 by Baptiste Mispelon, 10 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 Federico Capoano, 10 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 Federico Capoano, 10 years ago

Version: 1.2master

comment:24 by johmik, 10 years ago

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 by Claude Paroz, 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 Baptiste Mispelon, 10 years ago

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 by Russell Keith-Magee, 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 Areski Belaid, 10 years ago

Cc: Areski Belaid added

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

comment:29 by Tim Graham <timograham@…>, 10 years ago

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