添加链接
link管理
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接
  • Index
  • » Programming & Scripting
  • » [SOLVED]DJango 1.8 The TEMPLATE_DIRS setting must be a tuple.
  • [SOLVED]DJango 1.8 The TEMPLATE_DIRS setting must be a tuple.

    Hello, this is the error im getting when I try running a project with python manage.py runserver
    this is the full error message:
    http://pastebin.com/m0KHGPfq

    and these are my settings on settings.py :
    http://pastebin.com/4WgxCxVk

    I dont know what could be causing that... I tried some fixes but none of them worked for me.. The guide I'm following was made running a Windows computer, so maybe that's why I get the error. heres how its done on windows

    TEMPLATE_DIRS = (
    'C:/Users/Johnsmith/Django/app1/templates',
    )

    What I did was just change it to :

    TEMPLATE_DIRS = (
    '/home/Johnsmith/Documents/app1/templates',
    )
    So that may be the reason for the error..

    Last edited by leomisfits (2015-06-07 20:46:07)

    Re: [SOLVED]DJango 1.8 The TEMPLATE_DIRS setting must be a tuple.

    Are you sure that the guide you are following is for Djanjo 1.8?  Things have changed quite a bit.
    I don't think you are supposed to set TEMPLATE_DIRS.  My settings.py files for 1.8.1 do not.
    Also, my TEMPLATES dictionary  is defined as:

    TEMPLATES = [
            'BACKEND': 'django.template.backends.django.DjangoTemplates',
            'DIRS': [os.path.join(BASE_DIR, 'templates')],
            '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',
    ]

    Note that there is a DIRS key in this dictionary.  Mine is different from yours, and I did not change the template.  I think the array attached to the DIRS key is the place to add custom directories.  Also, check your email.


    Nothing is too wonderful to be true, if it be consistent with the laws of nature -- Michael Faraday
    The shortest way to ruin a country is to give power to demagogues.— Dionysius of Halicarnassus
    ---
    How to Ask Questions the Smart Way

    Re: [SOLVED]DJango 1.8 The TEMPLATE_DIRS setting must be a tuple.

    Okay, I see so for django 1.8 how do I set the path to the templates folder? Cuz im getting now this error :
    TemplateDoesNotExist at /hour/
    current_date.html
    Request Method:    GET
    Request URL: http://127.0.0.1:8000/hour/
    Django Version:    1.8.2
    Exception Type:    TemplateDoesNotExist
    Exception Value:
    current_date.html
    Exception Location:    /usr/lib/python3.4/site-packages/django/template/loader.py in get_template, line 46
    Python Executable:    /usr/bin/python
    Python Version:    3.4.3
    Python Path:
    ['/home/leonardo/Documents/app1',
    '/usr/lib/python34.zip',
    '/usr/lib/python3.4',
    '/usr/lib/python3.4/plat-linux',
    '/usr/lib/python3.4/lib-dynload',
    '/usr/lib/python3.4/site-packages']
    Server time:    Sun, 7 Jun 2015 20:28:13 +0000

    I deleted TEMPLATE_DIRS ... Now how would I tell python that the directory for the templates is located in '/home/leonardo/Documents/app1/templates'

    Also, the guide im reading says they are using django 1.6.2 ...The version im using is 1.8.2, huh

    Re: [SOLVED]DJango 1.8 The TEMPLATE_DIRS setting must be a tuple.

    You may want to look at the tutorials on the Django site itself.  They have some that are 1.8 specific.

    Note the official documentation defines what to do with the DIRS key. https://docs.djangoproject.com/en/1.8/topics/templates/

    Edit:  I see we were posting at the same time. smile Glad it is working.  But remember, 1.8 is a different animal that 1.6

    Last edited by ewaller (2015-06-07 20:54:57)


    Nothing is too wonderful to be true, if it be consistent with the laws of nature -- Michael Faraday
    The shortest way to ruin a country is to give power to demagogues.— Dionysius of Halicarnassus
    ---
    How to Ask Questions the Smart Way