Facing problem with rendering templates

Hello everyone. I’m currently working on a Django project and encountering an issue with template rendering. It’s not loading at all. I have conference app in my project. All apps are located in apps folder with one templates, in this templates there are templates with names of apps.

I have side navigation bar. When I click on ‘Conference Hall’ I face issue, template is not rendering

<li class="nav-item">
            <a class="nav-link" href="{% url 'conference' %}">
              <i class="ni ni-collection  text-blue"></i>
              <span class="nav-link-text">Conference Hall</span>

urls.py of conference app

from django.urls import path
from apps.conference import views

urlpatterns = [
    path('conference/', views.conference, name='conference')
    # Other URL patterns for your app's views...

views.py of conference app

from django.shortcuts import render
from django.contrib.auth.decorators import login_required

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

settings.py of project

import os
from decouple import config
from unipath import Path

# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
BASE_DIR = Path(__file__).parent
CORE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))

# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = config('SECRET_KEY', default='Sdhdsjqwi(2728_')

# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = config('DEBUG', default=True, cast=bool)

# load production server from .env
ALLOWED_HOSTS = ['localhost', '', config('SERVER', default='')]

# Application definition


    #my apps


ROOT_URLCONF = 'core.urls'
LOGIN_REDIRECT_URL = "home"  # Route defined in home/urls.py
LOGOUT_REDIRECT_URL = "home"  # Route defined in home/urls.py
TEMPLATE_DIR = os.path.join(CORE_DIR, "apps/templates")  # ROOT dir for templates

        'BACKEND': 'django.template.backends.django.DjangoTemplates',
        'DIRS': [TEMPLATE_DIR],
        'APP_DIRS': True,
        'OPTIONS': {
            'context_processors': [

WSGI_APPLICATION = 'core.wsgi.application'

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

    'default': {
        'ENGINE': 'django.db.backends.mysql',
        'NAME': 'ff',
        'USER': 'root',
        'PASSWORD': 'my_password',
        'HOST': 'localhost',
        'PORT': '3306',

# Password validation
# https://docs.djangoproject.com/en/3.0/ref/settings/#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/3.0/topics/i18n/


TIME_ZONE = 'New York'

USE_I18N = True

USE_L10N = True

USE_TZ = True

# SRC: https://devcenter.heroku.com/articles/django-assets

# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/1.9/howto/static-files/
STATIC_ROOT = os.path.join(CORE_DIR, 'staticfiles')
STATIC_URL = '/static/'

# Extra places for collectstatic to find static files.
    os.path.join(CORE_DIR, 'apps/static'),

core urls.py

from django.contrib import admin
from django.urls import path, include  # add this

urlpatterns = [
    path('admin/', admin.site.urls),          # Django admin route
    path("", include("apps.authentication.urls")), # Auth routes - login / register
    path("", include("apps.home.urls")),             # UI Kits Html files
    # path('', include('apps.photogallery.urls')),
    path('', include('apps.conference.urls')),


error handler

{% extends 'layouts/base-fullscreen.html' %}

{% block title %} Error 404 {% endblock title %}

<!-- Specific CSS goes HERE -->
{% block stylesheets %}{% endblock stylesheets %}

{% block content %}

    <!-- Page content -->
    <div class="container mt--8 pb-5">
      <div class="row justify-content-center">
        <div class="col-lg-5 col-md-7">
          <div class="card bg-secondary shadow border-0">
            <div class="card-header bg-transparent pb-5">

              <div class="text-muted text-center mt-2 mb-3">
                Error 500

              <div class="text-center mb-4">
                Page does not exist - <a href="/">Main page</a>.

          <div class="row mt-3">
            <div class="col-6">
              <a href="/" class="text-light"><small>Go to main page</small></a>
            <div class="col-6 text-right">
              <a target="_blank"
                 href="https://gf.kg/" class="text-light"><small>GF</small></a>

{% endblock content %}

<!-- Specific JS goes HERE -->
{% block javascripts %}{% endblock javascripts %}

May be I should change code in settings.py?
Thanks in advance!

When you say “it does not render”, do you get any specific error in the browser or server side? If so, please, post the errors you have.

Can you show how does core.urls module refers to conference/urls.py?

In conference/templates directory, do you have a conference subdirectory containing conference.html, or is conference.html directly under the templates directory? According to your view, the correct form is having conference/templates/conference/conference.html.

I have error handlers so page just does not load.
I have templates in apps directory and in this directory I have subdirectory with templates - these templates have name of app and there I keep html files of app

According to your TEMPLATES setting, Django searches for templates:

  • under installed applications directories: i.e.

    • apps/home/templates
    • apps/authentication/templates
    • apps/conference/templates
    • apps/chat/templates
  • in the directories referenced by DIR entry: i.e.:

    • apps/templates (assuming CORE_DIR is the argon-dashboard-django-master directory, which is the case if your settings.py file is in path argon-dashboard-django-master/<some project dir>/settings.py)

As your are splitting your project into apps, I would rather expect the templates for conference app to be under apps/conference/templates/, but if CORE_DIR is correctly defined (see my guess above), it should work this way.

To go further in debugging, can you explain what you mean by “I have error handlers”?

Also, when accessing the conference page, what do you get in the browser ?

By error handler I mean that when I need to get error on website or in terminal, I do not get it. I just see the page with error, code still works. When I try to access conference page I see my error handler. I provided code of this handler above

On a side note, this is a particularly bad idea:

At best, it’s a performance hit. At worst, it’s going to create unexpected conflicts between your different urls.

You really want to use some type of path differentiator for every included url file, except for possibly the last.

What should I change here?

Second side note: You appear to have created a non-standard directory structure for your project. This is likely going to be the first of a number of odd side effects you may encounter from doing so.

I suggest you reorganize your project into the standard layout for Django projects.

Define a url component for each of those path entries containing an include directive.

If I reorganize my project I will face other issues for sure

Why do you think that? I dare say there are a lot more people that use the standard project structure than don’t. I have only ever used the standard structure for the past 10 years and have never encountered a problem caused by it.

Thank you for advice, I will reorganize it. May be because not usual structure of project I face issues

I don’t know where does your error handler come from but it is inconsistent with title saying it’s a 404 error while body states a 500 error.

Please, can you clarify that ?

If this is your own override of django error templates, I think you should first work with standard django templates, as well as use standard django project architecture - as Ken sayed - before thinking overriding them.

Also, if it s a 500 error, you should have some logs server side, or, if running in DEBUG mode and use standard django error handlers, you will see exception traceback in the browser. This will help in debugging your issue