TemplateDoesNotExist at / template not defined

I have tried to set-up my first simple CBV in Django but despite reading literally all related information and trying out all possible path options to my index.html I receive the same message from above. Last version follows:

Python-Version: 3.9.13 Django: 4.1

**urls.py**

from django.urls import path
from core.views import Servicelist

urlpatterns = [
path('', Servicelist.as_view(), name='service')
]

**views.py**

from core.models import Item
from django.views.generic.list import ListView

class Servicelist(ListView):
    model = Item
    template_name:'paraticosmetics/index.html'
    context_object_name = "items"

    I receive message that index is not defined Pylance(reportundefinedVariable)


  **setting.py**


**setting.py**

INSTALLED_APPS = [
    "django.contrib.admin",
    "django.contrib.auth",
    "django.contrib.contenttypes",
    "django.contrib.sessions",
    "django.contrib.messages",
    "django.contrib.staticfiles",
    'django.contrib.sites',
    'allauth',
    'allauth.account',
    'allauth.socialaccount',
    'core.apps.CoreConfig',
     ]

 TEMPLATES = [
    {
          "BACKEND": "django.template.backends.django.DjangoTemplates",
          "DIRS": [BASE_DIR/'core/templates/paraticosmetics/'],
          "APP_DIRS": True,
   ....

Is your app called 'paraticosmetics'? Try adding that to your INSTALLED_APPS list

 'core.apps.CoreConfig',
 'paraticosmetics',
 ]

template_name:'paraticosmetics/index.html'

This line might be them problem you need = (a variable assignment) instead of : ( a type definition )

If not, show us the values of BASE_DIR, TEMPLATES and your project's directory structure.

Back to Top