resume_test
resume_test

Reputation: 171

Django test TemplateDoesNotExist

i hava a django pratice like this

│  manage.py
├─accounts
│  │  models.py
│  │  tests.py
│  │  urls.py
│  │  views.py
│  │  __init__.py
│  │
│  └─templates
│      └─accounts
│              detail.html
│              index.html
│              login.html
│              register.html
│
├─my_site
│      settings.py
│      urls.py
│      wsgi.py
│      __init__.py
│
└─templates
        base.html

when i write the test which is also inside django guide, when i test the assertRedirects, the "to" login.html will raise error described below bacause of this:

{% extends "base.html" %}

the error is this:

TemplateDoesNotExist: base.html

in my settings.py, TEMPLATE_DIRS looks like this

TEMPLATE_DIRS = (
    'templates'
)

so is there anyone tell my how to fix this?

Upvotes: 3

Views: 780

Answers (1)

shellbye
shellbye

Reputation: 4858

add this to your TEMPLATE_DIRS:

import os
TEMPLATE_DIRS = (
    'templates',
    os.path.join(os.path.dirname(__file__), '..', 'templates').replace('\\', '/')
)

Upvotes: 2

Related Questions