Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

django: how to add home link to admin

Tags:

django

admin

I would like to add a link to / to every page in template. Can I do it without changing django internal template? I could customize django, but this is something I seriously wouldn't like to do.

like image 320
gruszczy Avatar asked Jul 06 '11 14:07

gruszczy


People also ask

Where is admin site urls in Django?

Open a browser on the Django admin site http://127.0.0.1:8000/admin/.

Can I use Django admin as frontend?

Django Admin's task is to provide an interface to the admin of the web project. Django's Docs clearly state that Django Admin is not made for frontend work.


2 Answers

Sure, just override one of the Django admin templates in your own templates/admin directory. For instance, copy the contents of django/contrib/admin/templates/base.html into yourproject/templates/admin/base.html. Then, change the latter to your heart's content.

See: https://docs.djangoproject.com/en/dev/ref/contrib/admin/#overriding-admin-templates

like image 182
Chris Pratt Avatar answered Sep 22 '22 06:09

Chris Pratt


According to the accepted answer, I still failed to make it. After some try-error experiments, my answer is:

  1. copy django/contrib/admin/templates/base_site.html to as your_project/templates/admin/base_site.html

  2. customize your local base_site.html to whatever you want

  3. add to your settings.py

    TEMPLATE_DIRS = ('templates',)

like image 38
Xiaoli Avatar answered Sep 23 '22 06:09

Xiaoli