Opened 10 years ago

Closed 10 years ago

#21378 closed Bug (fixed)

Outdated way to change admin site header in tutorial02

Reported by: Vajrasky Kok Owned by: Vajrasky Kok
Component: Documentation Version: dev
Severity: Normal Keywords:
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: yes
Easy pickings: no UI/UX: no

Description

https://docs.djangoproject.com/en/dev/intro/tutorial02/

In the development version (1.7 if you come from the future) of tutorial02, the way to change admin site header ("Django administration") is wrong. It tells us to override the template and:

"Then, just edit the file and replace the generic Django text with your own site’s name as you see fit."

But there is no "generic Django text".

I think the proper way is to subclass admin site and change site_header class attribute.

Change History (8)

comment:1 by Vajrasky Kok, 10 years ago

Has patch: set
Status: newassigned

Here is the preliminary PR.

https://github.com/django/django/pull/1855

comment:2 by chrismedrela, 10 years ago

Summary: In 1.7 (master) version of tutorial02, the way to change admin site header is wrongOutdated way to change admin site header in tutorial02
Triage Stage: UnreviewedAccepted

The documentation was outdated by https://github.com/django/django/commit/a962286b74f1e8c8cb19fb45a057800da8c2fb56 commit which replaced hardcoded "Django administrator" header text with a new Site.site_header attribute.

comment:3 by chrismedrela, 10 years ago

Patch needs improvement: set

Comments on PR.

comment:4 by Vajrasky Kok, 10 years ago

There is a way to change site header with shorter code. Instead of subclassing AdminSite, we can set site_header attribute of default admin.site directly.

admin.site.site_header = "Cute Cat Entreprise"
admin.site.register(Poll, PollAdmin)

But I am not sure whether this is Djangonic or not.

Okay, why don't we wait other people's (especially core developers) comments about this. Once we agree what to do, I'll update PR. Thanks for the review!

comment:5 by G.Z., 10 years ago

My 2 cents: since the tutorial is aimed at new users, I would avoid adding such a long part just to change the header. Finding an easier way to do it would be better, or maybe having the explanation somewhere else and having a link to it?

comment:6 by Tim Graham, 10 years ago

I suggest keeping the existing text of the tutorial and just briefly pointing out the alternative site_header attribute at the end in one sentence. e.g. "We used this approach to teach you how to override templates. In an actual project, you can probably simply use the site_header attribute."

comment:7 by Vajrasky Kok, 10 years ago

Okay, thanks for the input and here is the revised PR: https://github.com/django/django/pull/1899

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

Resolution: fixed
Status: assignedclosed

In 10a39debb2b95b41c8c4ec53247a3d1efe6c7f1b:

Fixed #21378 -- Updated tutorial02 for how to override admin site header.

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