Mervin Joseph
Mervin Joseph

Reputation: 87

Django/Python TemplateDoesNotExist at / base.html

I am currently trying to learn Python and was watching some tutorials on youtube. I had thought of learning how to deploy dashboards to django and came across this tutorial. I was able to follow on the tutorial but when I try to run my code, I am receiving an error enter image description here

I did what was in the tutorial and this is my file and codes

enter image description here

Home App URLS.PY

from django.urls import path
from . import views

urlpatterns = [
    path('', views.home, name='home')
]

Home App VIEWS.PY

from django.shortcuts import render
   
def home(requests):
    return render(requests, 'home/welcome.html')

Setting.py

INSTALLED_APPS = [
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'home.apps.HomeConfig',
]

STATICFILES_LOCATION = 'static'
STATIC_URL = '/static/'
STATIC_ROOT = 'static'
STATIC_DIR = [
    os.path.join(BASE_DIR, 'slsuhris/static'),
]

Project URLS.PY

from django.contrib import admin
from django.urls import path, include

urlpatterns = [
    path('admin/', admin.site.urls),
    path('', include('home.urls')),
]

I have followed tutorial except for the migration using PostgreSQL thinking that it isn't necessary for building a dashboard. Why can't I access the files? Thank you.

I am using Python Community Edition. Does having error on the <!doctype html> got to do with this error?

enter image description here

Upvotes: 0

Views: 374

Answers (1)

Razenstein
Razenstein

Reputation: 3717

Sorry my mistake ... you are right, your base.html is in templates and this is what you need in settings.py:

TEMPLATES = 

....
        'DIRS': [os.path.join(BASE_DIR, 'templates')]
....

Upvotes: 1

Related Questions