bittner / django-apptemplates

Django template loader that allows you to load and override a template from a specific Django application.
https://pypi.python.org/pypi/django-apptemplates
MIT License
51 stars 12 forks source link

Settings KeyError: APP_DIRS must not be set when loaders is defined #16

Closed dancaron closed 3 years ago

dancaron commented 3 years ago

Context: Trying to over ride base_site.html when using django-admin-interface package. I have one file in main/templates/admin, which is base_site.html. And have {% extends "admin_interface:admin/base_site.html" %} at top.

KeyError:

"app_dirs must not be set when loaders is defined."
django.core.exceptions.ImproperlyConfigured: app_dirs must not be set when loaders is defined.

settings.py

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

Removing 'APP_DIRS' causes a TEMPLATE DOES NOT EXIST error.

Using django-admin-interface package.

dancaron commented 3 years ago

Removing 'APP_DIRS' and adding django.template.loaders.app_directories.Loader to 'loaders' seems to have solved the issue.

bittner commented 3 years ago

In other words, you don't need django-apptemplates at all anymore for your use case? Can you confirm?

dancaron commented 3 years ago

After I changed the order of my INSTALLED_APPS, I was able to override django-admin-interface package without django-apptemplates. Appreciate the quick response.

pboes commented 1 year ago

@dancaron I'm facing the exact same issue in the exact same context. Do you happen to remember what exactly you did to overwrite django-admin-interface? Thanks

dancaron commented 1 year ago

@pboes Sorry, just getting to this message now. Did you resolve your issue?

dancaron commented 1 year ago

@pboes Check INSTALLED_APPS, and try moving the order of the entries up or down.

pboes commented 1 year ago

Thanks @dancaron, I did solve it in the end. Thanks for getting back to me.