#21378 closed Bug (fixed)

Outdated way to change admin site header in tutorial02

Reported by: vajrasky Owned by: vajrasky
Component: Documentation Version: master
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 Changed 20 months ago by vajrasky

  • Has patch set
  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Status changed from new to assigned

Here is the preliminary PR.

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

comment:2 Changed 20 months ago by chrismedrela

  • Summary changed from In 1.7 (master) version of tutorial02, the way to change admin site header is wrong to Outdated way to change admin site header in tutorial02
  • Triage Stage changed from Unreviewed to Accepted

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 Changed 20 months ago by chrismedrela

  • Patch needs improvement set

Comments on PR.

comment:4 Changed 20 months ago by vajrasky

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 Changed 20 months ago by G.Z.

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 Changed 20 months ago by timo

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 Changed 20 months ago by vajrasky

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

comment:8 Changed 20 months ago by Tim Graham <timograham@…>

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

In 10a39debb2b95b41c8c4ec53247a3d1efe6c7f1b:

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

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