Answers for "add template in django"

1

dirs' base_dir / 'templates' error

Incorrect syntax in polls app tutorial by Django

Use this: 
os.path.join(BASE_DIR, 'templates')

instead of this:
BASE_DIR / 'templates'

TEMPLATES = [
    {
        'BACKEND': 'django.template.backends.django.DjangoTemplates',
        'DIRS': [os.path.join(BASE_DIR, 'templates')],
        'APP_DIRS': True,
        'OPTIONS': {
            'context_processors': [
                # codes...
            ],
        },
    },
]
Posted by: Guest on October-04-2020
1

how to connect templates in django

# Template directory setting
TEMPLATE_DIRS = (
    os.path.join(os.path.dirname(__file__), 'templates'),
)
Posted by: Guest on April-05-2021

Python Answers by Framework

Browse Popular Code Answers by Language