Versions
Python 3.11
Django 4.2
WhiteNoise 6.6.0
I’m currently in the process of deploying my website into the big bad world.
I have installed Whitenoise (thenceforth will be referred to as “WN”) from [PyPi](https://pypi.org/project/whitenoise/)
and have followed the documentation in installing and setting up WN in accordance with [ReadTheDocs](https://whitenoise.readthedocs.io/en/stable/django.html)
I have then run the python manage.py collectstatic
command with no issues and I now have a static folder in the root directory which contains all of my static files - which is what is supposed to happen.
I have set my ALLOWED_HOSTS
to ALLOWED_HOSTS = ["127.0.0.1"]
and have also tried ALLOWED_HOSTS = ["*"]
in my settings.py
file.
I hit the python manage.py runserver
command & everything up until this point runs the development server with no issues, my website runs as expected and the only console warning is a message stating that third party cookies will be blocked which I don’t believe has anything to do with the issue at hand.
However, I hit the DEBUG = False
and once again - as expected - VSC give me the Starting development server at http://127.0.0.1:8000/
message in the console.
I click on the link and it give me the A server error occurred. Please contact the administrator.
Opening the error console back up in the browser, it returns:
Failed to load resource: the server responded with a status of 500 (Internal Server Error)
Helpful! However, I run the settings.py
file and it appears not to like the {% block content %} tag because the VSC console returns:
django.template.exceptions.TemplateSyntaxError: Invalid block tag on line 22: 'content'. Did you forget to register or load this tag?
I am fully aware as to what this is referring to - it is a template tag that is widely used in Django to separate content in your base.html
and is applied to all templates with which uses the {% extends 'base.html' %}
and takes the form:
`{% block content %}
{% endblock %}`
However, I fail to see why this is an issue as I have not only set {% load static %}
at the top of every Django template but also this is widely used template tag.
-
Could this disliking on the part of Django of this
content
template tag be the cause of theError 500
-
if the above is true, how would I go about rectifying this?
Many thanks