Django 1.9 + admin interface setup

I am using Django1.9 and trying to override the admin interface.

I referenced the following link to override the admin header

http://stackoverflow.com/questions/4938491/django-admin-change-header-django-administration-text 

As mentioned in the post, my src-> Templates-> admin-> base_site.html directory / file structure

base_site.html

 {% extends "admin/base.html" %} {% block title %}Personal Site{% endblock %} {% block branding %} <h1 id="site-name"><a href="{% url 'admin:index' %}">Control Panel</a></h1> {% endblock %} {% block nav-global %}{% endblock %} 

But this page is not called. I copied the code base_site.html from https://github.com/django/django/blob/master/django/contrib/admin/templates/admin/base_site.html

& title changes made.

I know I can configure the admin header in django, but that is not what I am looking for. My long-term goal is to customize the entire admin user interface. So please explain to me how I can get this custom template page to be called.

Here are the settings for my template:

 TEMPLATES = [ { 'BACKEND': 'django.template.backends.django.DjangoTemplates', 'DIRS': [ os.path.join(BASE_DIR,'templates'), ], 'OPTIONS': { 'context_processors': [ 'django.template.context_processors.debug', 'django.template.context_processors.request', 'django.contrib.auth.context_processors.auth', 'django.contrib.messages.context_processors.messages', ], 'loaders':[ 'django.template.loaders.filesystem.Loader', 'django.template.loaders.app_directories.Loader' ] }, }, ] 

Thanks Aniruddha

+6
source share
1 answer

configure project contrib/admin/templates/admin directories in the contrib/admin/templates/admin directory.

To override - Create a customadmin directory in the templates directory.

  • You can also configure the "bootloaders" option by adding " django.template.loaders.filesystem.Loader " (should be written earlier)
  • django.template.loaders.app_directories.Loader .

This will load custom templates before default.

Create directories in customadmin and name them as the application if you want to override the application.

In the above subdirectories, create directories for the models and name them as the model to override the model.

Create a custom advanced template (in most cases, an html file) in the desired directory.

Congratulations. You have expanded the default administrator.

+5
source

All Articles