简体   繁体   中英

Django Admin Panel

I am trying to set up a new blog. I want to keep all my project templates folder in the same folder as where my settings.py is. To do this I did the following... [...]

TEMPLATES = [
    {
        'BACKEND': 'django.template.backends.django.DjangoTemplates',
        'DIRS': [os.path.join(BASE_DIR, "templates/")],
        'APP_DIRS': False,
        'OPTIONS': {
            'context_processors': [

[...]

But now, my admin panel layout doesn't work. How can I circumvent the above solution when using the admin panel? I get the error

Exception Type: TemplateDoesNotExist Exception Value: admin/login.html

By disabling APP_DIRS you're forcing Django to look for your templates in the templates folder of your basedir regardless of where the app specifies them. This will break any plugins and also prevents you from namespacing templates. Its generally a bad idea.

DIRS is a list, so you can specify multiple locations if desperately want to hold the templates in a different locationand maintain access to teh admin

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM