Bussiere
Bussiere

Reputation: 1154

Error with the template path in django 2.0

Here is my settings.py :

PROJECT_ROOT = os.path.abspath(os.path.dirname(__file__))
TEMPLATE_DIRS = (
    # Put strings here, like "/home/html/django_templates" or "C:/www/django/templates".
    # Always use forward slashes, even on Windows.
    # Don't forget to use absolute paths, not relative paths.
    #os.path.join(PROJECT_ROOT, 'templates').replace('\\','/'),
    "templates",
)

TEMPLATES = [
    {
        'BACKEND': 'django.template.backends.django.DjangoTemplates',
        'DIRS': [TEMPLATE_DIRS],
        'APP_DIRS': True,
        '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',
            ],
        },
    },
]

So here is my error :

Using engine django:

django.template.loaders.filesystem.Loader: /home/bussiere/Workspace/Bourse/Event/('templates',)/index.html (Source does not exist) django.template.loaders.app_directories.Loader: /usr/local/lib/python3.5/dist-packages/django/contrib/admin/templates/index.html (Source does not exist) django.template.loaders.app_directories.Loader: /usr/local/lib/python3.5/dist-packages/django/contrib/auth/templates/index.html (Source does not exist) Traceback Switch t

i don't understand this url :

/home/bussiere/Workspace/Bourse/Event/('templates',)/index.html (Source does not exist) 

here is my version of django :

-> % django-admin version 2.0

If you have any idea why

regards

Upvotes: 0

Views: 547

Answers (1)

Daniel Roseman
Daniel Roseman

Reputation: 599610

You've taken your TEMPLATE_DIRS setting, which is a tuple, and wrapped it in a list to add it to your TEMPLATES setting. Don't wrap it:

    'DIRS': TEMPLATE_DIRS,

Even better, remove the TEMPLATE_DIRS setting completely and define it directly inline:

    'DIRS': ['templates'],

Also note the clear direction in that original setting: "Don't forget to use absolute paths".

    'DIRS': [os.path.join(BASE_DIR, 'templates')],

Upvotes: 5

Related Questions