2

I am newly learning Django and was following the Learn Django 1.11 Tutorial.

Here is my current project tree:

├── manage.py
├── muypicky
│   ├── __init__.py
│   ├── old_settings.py
│   ├── settings
│   │   ├── base.py      # Contains the settings (like shown in the tutorial)
│   │   ├── __init__.py
│   ├── urls.py
│   └── wsgi.py
├── requirements.txt
├── restaurants
└── templates           # Templates Folder
└── index.html

I am trying to add the path to the tempelates folder in the settings folder. But the error shown

django.template.loaders.filesystem.Loader: .../muypicky/tempelates/index.html (Source does not exist)

Current setting.py file

TEMPLATES = [{
  'DIRS': [os.path.join(BASE_DIR, 'tempelates')], 
  },]

Looking at the error, the file path is wrong because it goes into /muypicky/tempelates which is incorrect. So how do I get to root folder and then into tempelates folder with the given file tree in setting.py (base.py).

Any further queries, just ask and many thanks in anticipation.

eyllanesc
  • 235,170
  • 19
  • 170
  • 241
ByWaleed
  • 395
  • 4
  • 18

3 Answers3

4

You have probably misspelled the name because the directory is called templates but your settings.py is looking for templates

├── manage.py
...
└── templates           # Templates Folder
└── index.html

but in your settings you stated templates

TEMPLATES = [{
  'DIRS': [os.path.join(BASE_DIR, 'templates')], 
  },]

That's why Djagno can't find the file

.../muypicky/templates/index.html (Source does not exist)

Papouche Guinslyzinho
  • 5,277
  • 14
  • 58
  • 101
  • Still doesn't work. Even after fixing the spelling error, I still get '''muypicky/templates/index.html (Source does not exist)'''. I think it's more to do with the BASE_DIR in base.py whis is like this: '''BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))''' – ByWaleed Aug 26 '17 at 19:25
  • Also to note, when I add the exact path on my system to the templates folder, it does work, which is why I think it's my BASE_DIR causing the issue. – ByWaleed Aug 26 '17 at 19:31
  • 1
    Haha, your fix to include his misspelt templates is both humourous and helpful. – Peter Chaula Nov 08 '20 at 18:51
4

I have the same project tree and in TEMPLATES I put :

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

]

Marouan
  • 56
  • 1
2

Typo. Change 'tempelates' to 'templates'.