How to fix this error: Template Does Not Exist ? Django

Wyndham Keith

urls.py

from django.urls import path

from . import views

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

another urls.py

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

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

settings.py - templates

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

views.py

from django.shortcuts import render
from django.http import HttpResponse

def home(request):
    return render(request, 'templates/home.html')

I am stuck here, tried changing many already, still won't work, the 500(Template does not exist), what is the right code?

Thanks in advance!

Manoj Tolagekar

In your settings.py file:

inside TEMPLATES, just add this:

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

Ex:

TEMPLATES = [
    {
        'BACKEND': 'django.template.backends.django.DjangoTemplates',
        'DIRS': [os.path.join(BASE_DIR, 'templates')], #Added here
        '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',
            ]
        },
    },
]

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

Angular - How to fix 'property does not exist on type' error?

Ansible template - Destination directory does not exist error

How to fix the error - The target "_CopyBinDeployableAssemblies" does not exist in the project?

How to fix "Class signed does not exist" error in Laravel 5.7?

How To fix 'Property "string" does not exist on type "object"' error in Typescript

How to fix “ERROR: column relhasoids does not exist” in phpPgAdmin?

Django template does not exist include or extends tags

Django template does not exist @

How to fix a missing template error?

Error: Template Does Not Exist

How to fix this class template error?

django render template does not exist

How to fix Postgres error column does not exist?

template does not exist error in django?

How can I fix this Java with PostgreSQL error (table does not exist)?

How to fix "relation does not exist"

How to fix Node "options" does not exist for Node "Drupal\Core\Template\TwigNodeTrans"

Template does not exist error when template exists

template does not exist in django

How to fix property does not exist on type 'Element' error in Typescript?

How to fix drupalvm error: playbook does not exist on the guest?

How to fix matchong query does not exist error?

Template does not exist in django, but I have template?

How to fix a 404 error when the object does exist?

Template does not exist for django authentication views

how to fix the error : Property 'X' does not exist on type '{ object }'

how to fix template does not exist in Django?

How to fix this error: Template Does Not Exist?

Django: Template does not exist