开发者

django: how to add home link to 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 customiz开发者_如何学Pythone django, but this is something I seriously wouldn't like to do.


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


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',)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜