TemplateDoesNotExist at /blog/create/

Not sure if its a typo or not... I don't understand why I am getting this error:

enter image description here

getting TemplateDoesNotExist error? weird because when I click on create post it takes me to ".../blog/create/"

can someone help please!

"

base.hmtl '''

This is the Title {% include 'snippets/header.html' %}
<style type="text/css">
    .main{
        min-height: 100vh;
        height: 100%;
    }
</style>
<div class="main">
    {% block content %}

    {% endblock content %}
</div>


{% include 'snippets/footer.html' %}

**create.html (inside blog/Template/blog) **

{% extends 'base.html' %}

{% block content %}

    <p>Create a new blog...</p>

{% endblock content %}

** urls.py (inside blog folder)**

from django.urls import path
from blog.views import(
    
    create_blog_view,
)

app_name = 'blog'

urlpatterns = [
    path('create/', create_blog_view, name="create"),
]

urls.py (in mysite folder)

from django.contrib import admin
from django.urls import path, include
from django.conf import settings
from django.conf.urls.static import static
from personal.views import (
    home_screen_view,
)

from account.views import (
    registration_view,
    logout_view,
    login_view,
    account_view,
)

urlpatterns = [
    path('admin/', admin.site.urls),
    path('', home_screen_view, name="home"),
    path('register/', registration_view, name="register"),
    path('blog/', include('blog.urls', 'blog')),
    path('logout/', logout_view, name="logout"),
    path('login/', login_view, name="login"),
    path('account/', account_view, name="account"),

]

if settings.DEBUG:
    urlpatterns += static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)
    urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)

views.py (inside blog)

from django.shortcuts import render
from blog.models import BlogPost

def create_blog_view(request):
    return render(request, "blog/create.html", {})

home.html(inside personal/Template/snippets)

{% extends 'base.html' %}

{% block content %}

<style type="text/css">
    @media (max-width: 768px) { 
        .right-column{
            margin-left: 0px;
        }
    }

    @media (min-width: 768px) { 
        .right-column{
            margin-left: 20px;
        }
    }

    .blog-post-container{
        background-color: #fff;
        margin-bottom: 20px;
        width: 100%;
    }
    .create-post-bar{
        background-color: #fff;
        margin-bottom:20px;
    }

    .left-column{
        padding:0px;
    }

    .right-column{
        padding:0px;
    }

</style>

<div class="container">
    <div class="row">
        
        <!-- create post bar -->

        <div class="create-post-bar d-lg-none col-lg-7 offset-lg-1">
            <a href="{% url 'blog:create' %}">Create post</a>
        </div>

        <!-- end create post bar-->

        <!-- Blog feed -->

        <div class="left-column col-lg-7 offset-lg-1">
            <div class="blog-post-container">
                <p>Thingy</p>
            </div>

            <div class="blog-post-container">
                <p>Thingy</p>
            </div>

            <div class="blog-post-container">
                <p>Thingy</p>
            </div>
        </div>

        <!-- end Blog feed-->

        <!-- create post column -->

        <div class="right-column col-lg-3 d-lg-flex d-none flex-column">
            <div class="create-post-bar">
                <p>Stuff</p>
                <p>Stuff</p>
                <p>Stuff</p>
                <a class="p-2 btn btn-outline-primary" href="{% url 'blog:create' %}">Create post</a>
            </div>
        </div>

        <!-- end create post column-->
    </div>
</div>



{% endblock content %}
from pathlib import Path

import os

# Build paths inside the project like this: BASE_DIR / 'subdir'.
BASE_DIR = Path(__file__).resolve().parent.parent


# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/4.1/howto/deployment/checklist/

# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = 'django-insecure-69h2zg+w5&_a&_qkb#r(z%w4tcwn^7k4m0zdz2c#r+7_z6est5'

# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True

ALLOWED_HOSTS = []


# Application definition

INSTALLED_APPS = [
    
    #My apps
    'personal',
    'account',
    'blog',

    #Djangos apps

    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
]

MIDDLEWARE = [
    'django.middleware.security.SecurityMiddleware',
    'django.contrib.sessions.middleware.SessionMiddleware',
    'django.middleware.common.CommonMiddleware',
    'django.middleware.csrf.CsrfViewMiddleware',
    'django.contrib.auth.middleware.AuthenticationMiddleware',
    'django.contrib.messages.middleware.MessageMiddleware',
    'django.middleware.clickjacking.XFrameOptionsMiddleware',
]

ROOT_URLCONF = 'mysite.urls'

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

AUTH_USER_MODEL = 'account.Account'

WSGI_APPLICATION = 'mysite.wsgi.application'


# Database
# https://docs.djangoproject.com/en/4.1/ref/settings/#databases

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.sqlite3',
        'NAME': BASE_DIR / 'db.sqlite3',
    }
}


# Password validation
# https://docs.djangoproject.com/en/4.1/ref/settings/#auth-password-validators

AUTH_PASSWORD_VALIDATORS = [
    {
        'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
    },
    {
        'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
    },
    {
        'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
    },
    {
        'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
    },
]


# Internationalization
# https://docs.djangoproject.com/en/4.1/topics/i18n/

LANGUAGE_CODE = 'en-us'

TIME_ZONE = 'UTC'

USE_I18N = True
USE_L10N = True

USE_TZ = True


# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/4.1/howto/static-files/

STATICFILES_DIRS = [
    os.path.join(BASE_DIR, 'static'),
    os.path.join(BASE_DIR, 'media'),
]
STATIC_URL = '/static/'
MEDIA_URL = '/media/'
STATIC_ROOT = os.path.join(BASE_DIR, 'static_cdn')
MEDIA_ROOT = os.path.join(BASE_DIR, 'media_cdn')

# Default primary key field type
# https://docs.djangoproject.com/en/4.1/ref/settings/#default-auto-field

DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'

"

I was expecting it to redirect me to the new page but it shows an error

Apparently your app doesn't look into blog's template folder. It only looks into personal and account's template folders. You can check that in the attached picture under template-loader postmortem. It usually means that the app is not installed properly.

There are lots of reasons for such a thing, among them:

  • You might have located it in a wrong directory. The app must be at ./src/. It seems that it's not the case as the url.py is working properly.
  • It might be the case that you forgot to save settings.py after you added the blog app.
  • It might be your virtual environment. A restart and a migrate command might help.

Otherwise you might have changed the app's template directory somewhere.

You have the configuration

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

so you need to have the Templates directory in your base directory, not inside each app, it should be

Template/blog/create.html

and not

blog/Template/blog/create.html

With APP_DIRS enabled Django searches for templates inside each app /templates/ subfolder. Lowercase, plural.

You have Template - wrong case, missing s in the end. So yes, the template does not exist for Django because it cannot find at any expected location.

Back to Top