django 1.9 and registration/login.html django 1.9 and registration/login.html django django

django 1.9 and registration/login.html


This question appears first in search engine with searching for registration/login.html : Template Does Not Exist

So for those coming through search engine, please note that this template doesn't come by default with Django. If you haven't created it, that's why you are getting this error

Here is how you can create a simple onehttps://simpleisbetterthancomplex.com/tutorial/2016/06/27/how-to-use-djangos-built-in-login-system.html


Try to put your template dirs paths in DIRS list inside TEMPLATES setting. (Anyway, your template folder name should be templates not template.)

TEMPLATES = [{    'BACKEND': 'django.template.backends.django.DjangoTemplates',    'DIRS': [join(BASE_DIR, 'webgui/template/registration'),join(BASE_DIR, 'webgui/template/')],    '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',        ],    },},]


After upgrading my django to 1.9.1, same thing happened to me. Apparently, there are updates on templates directory.Here is how I fixed it.

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',        ],    },},]

Of course you should have BASE_DIR defined

BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))

After that,I've deleted the templates folder and created a templates folder for each app. So, inside the each app, just create templates and put the html files inside.

Also in views, connect it to the html file like this.

def index(request):    context_dict = {}    return render(request, 'index.html', context_dict)

This worked for me.