Template does not exist: 500.html
Asked Answered
C

3

13

I have created a template for the 500 HTTP error.

I have inserted my template 500.html in:

  1. /project/
  2. /project/templates/
  3. /python2.5/
  4. /python2.5/templates/

but I always get this error:

TemplateDoesNotExist: 500.html

I get the same problem for an HTTP 404 error.

Why?

Chromate answered 12/5, 2010 at 20:13 Comment(0)
G
11

You might need to specify the template directories in settings.py, if you haven't already.

e.g. in my settings.py, I have:

ROOTDIR = os.path.abspath(os.path.dirname(__file__)) 
TEMPLATE_DIRS = (
    # Put strings here, like "/home/html/django_templates" or "C:/www/django/templates".
    # Always use forward slashes, even on Windows.
    # Don't forget to use absolute paths, not relative paths.
    ROOTDIR + '/logistics/templates',
)
Guinn answered 12/5, 2010 at 20:20 Comment(1)
First, try adding this to your template_dirs: C:\Python25\Lib\site-packages\django\contrib\admin\templates\admin and see if that loads the default Django templates at all... And, if it does, then you're not specifying your dirs correctly. Note: my python instance and installed at C:\, change the path to whatever is right for your system.Guinn
M
5

Try to set
DEBUG=True in your settings file

Movable answered 12/9, 2011 at 13:28 Comment(4)
Definitely not on a production machine.Basketry
But on a devel machine it's quite useful. I couldn't remember why I didn't get debug messages anymore, so this hint is rather helpful. Thanks! :)Reseau
Normally this error occurs once setting up the installation the first time, by which you probably don't have lots of traffic. The standard error logging only helps you so much.Manthei
Debug True at least said something more to fix the bug, thanks a lot!Improvvisatore
B
0

You need to update your "Templates" configuration in your setting file like the below: enter image description here

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

Worked for me.

Billat answered 19/6, 2023 at 13:36 Comment(2)
Hi @Abiola thanks for giving a look at this, but we believe how it would help is by providing relevant reference or sample.Epiblast
@SuryaBhusal, see the updated solution above. "DIRS": is usually empty for new projects, so update it to properly point in the right folder for Django to find your templates.Billat

© 2022 - 2024 — McMap. All rights reserved.