8👍
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',
],
},
},
]
20👍
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 one
https://simpleisbetterthancomplex.com/tutorial/2016/06/27/how-to-use-djangos-built-in-login-system.html
8👍
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.
- Django: WSGIRequest' object has no attribute 'user' on some pages?
- Where has 'django.core.context_processors.request' gone in Django 1.10?
- Efficient function to retrieve a queryset of ancestors of an mptt queryset
- Ruby HAML with Django?
4👍
You have set 'APP_DIRS': True,
, so Django will search for templates
directories inside each app in INSTALLED_APPS
, including your webgui
app.
The problem is that you have named your directory webgui/template/
instead of webgui/templates/
, so the app loader won’t find it.
The easiest fix is to rename your directory. If you don’t want to do this, you’ll have to add the webgui/template
directory to your DIRS
option.
- How can I easily convert a Django app from mySQL to PostgreSQL?
- Psycopg2 cannot connect to docker image