Monday, October 20, 2014

Re: Customize admin page title (from tutorial)

Hi Pat,

On 10/18/2014 03:47 PM, Pat Claffey wrote:
> Hi,
> yes this is possible. I have recently done this tutorial and succeeded
> in customizing the title.
> In my opinion the instructions in this part of the tutorial are hard to
> understand. Here is what I did:
>
> 1.0 Navigate to the project directory mysite/mysite/
> 2.0 Create a new sub-directory called templates. You should now have a
> directory mysite/mysite/templates/
> 3.0 Create a new sub-directory called admin in the above templates
> sub-directory. You should now have a directory
> mysite/mysite/templates/admin/
> 4.0 Edit the settings file (mysite/settings.py) and add a TEMPLATE_DIRS
> setting:
> TEMPLATE_DIRS = [os.path.join(BASE_DIR, 'templates')]
> 5.0 Find the path of the django source files on your system.
> To find this path open the python interpreter; import django and print
> the value of django.__path__ using the python command print(django.__path__)
> 6.0 On your file system navigate to the directory path obtained above
> from django.__path__ variable. You should see a directory called
> contrib. navigate to contrib/admin/templates/admin/
> You should see a source file called base_site.html
> 7.0 Copy the above source file base_site.html into the directory
> mysite/mysite/templates/admin/. You should now have a file
> mysite/mysite/templates/admin/base_site.html
> 8.0 Edit the above file and replace {{ site_header|default:_('Django
> administration') }} (including the curly braces) with the new site name.
> If the desired new site name is "My Company Name" then you should see
> <h1 id="site-name"><a href="{% url 'admin:index' %}">My Company
> Name</a></h1>
> 9.0 Open the admin screen. You may need to refresh this page. You
> should now see that the label at the top of the page has changed.

I think these instructions are correct, except for the paths. Unless
you've modified the definition of the BASE_DIR setting in the default
Django project template, BASE_DIR will point to the outer workspace
"mysite" directory, not the inner Python package (mysite/mysite). So
you'd want to create `mysite/templates`, not `mysite/mysite/templates`,
to match a TEMPLATE_DIRS setting of `[os.path.join(BASE_DIR, 'templates')]`.

I'm not sure how to explain your success using the above steps. Perhaps
you have `'mysite'` in your INSTALLED_APPS, and thus your templates in
`mysite/mysite/templates` are being picked up by the app-dirs template
loader?

Carl

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/5445529A.4020506%40oddbird.net.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment