A
A
Artyom Innokentiev2016-01-23 12:18:57
Django
Artyom Innokentiev, 2016-01-23 12:18:57

How to fix errors when displaying admin templates?

settings.py:

TEMPLATES = [
    {
        'BACKEND': 'django.template.backends.django.DjangoTemplates',
        'DIRS': [os.path.join(BASE_DIR, 'templates/')],
        'APP_DIRS': False,
        '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',
            ],
        },
    },
]
INSTALLED_APPS = (
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
)

When trying to go to /admin, Django throws a TemplateDoesNotExist error - it looks for a template in the local directory /templates and does not look in site-packages/django/contrib/admin/templates where they are (checked).
Of course, if you directly write the path to site-packages in DIRS, everything works, but when transferring to a combat one, registering the path every time is not a good option.
How can this be fixed? How to set the default path to site-packages?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vladimir, 2016-01-23
@artinnok

TEMPLATES = [
    {
        'BACKEND': 'django.template.backends.django.DjangoTemplates',
        'DIRS': ,
        'APP_DIRS': True,
        'OPTIONS': {
            'context_processors': [
                'django.template.context_processors.debug',
                'django.template.context_processors.request',
                'django.contrib.auth.context_processors.auth',
                "django.core.context_processors.i18n",
                "django.core.context_processors.media",
                'django.contrib.messages.context_processors.messages',
                'django.core.context_processors.request',
            ],
        },
    },

]

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question