0

So I get the Internal Server Error message come up on my browser when I set DEBUG = False after I correctly have set up gunicorn and nginx and I'm currently in production mode.

In Debug, all is fine, when Debug is off, I get the following message:

The trace error is as follows:

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\XXXXX\AppData\Local\Programs\Python\Python312\Lib\wsgiref\handlers.py", line 137, in run
    self.result = application(self.environ, self.start_response)
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "c:\Users\xxxx\xxx\<PROJECTNAME>\.venv\Lib\site-packages\django\core\handlers\wsgi.py", line 124, in __call__
    response = self.get_response(request)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "c:\Users\xxxx\xxx\<PROJECTNAME>\.venv\Lib\site-packages\django\core\handlers\base.py", line 140, in get_response
    response = self._middleware_chain(request)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "c:\Users\xxxx\xxx\<PROJECTNAME>\.venv\Lib\site-packages\django\core\handlers\exception.py", line 57, in inner
    response = response_for_exception(request, exc)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "c:\Users\xxxx\xxx\<PROJECTNAME>\.venv\Lib\site-packages\django\core\handlers\exception.py", line 140, in response_for_exception  
    response = handle_uncaught_exception(
               ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "c:\Users\xxxx\xxx\<PROJECTNAME>\.venv\Lib\site-packages\django\core\handlers\exception.py", line 185, in handle_uncaught_exception
    return callback(request)
           ^^^^^^^^^^^^^^^^^
  File "c:\Users\xxxx\xxx\<PROJECTNAME>\.venv\Lib\site-packages\django\utils\decorators.py", line 188, in _view_wrapper
    result = _process_exception(request, e)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "c:\Users\xxxx\xxx\<PROJECTNAME>\.venv\Lib\site-packages\django\utils\decorators.py", line 186, in _view_wrapper
    response = view_func(request, *args, **kwargs)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "c:\Users\xxxx\xxx\<PROJECTNAME>\.venv\Lib\site-packages\django\views\defaults.py", line 91, in server_error
    template = loader.get_template(template_name)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "c:\Users\xxxx\xxx\<PROJECTNAME>\.venv\Lib\site-packages\django\template\loader.py", line 15, in get_template
    return engine.get_template(template_name)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "c:\Users\xxxx\xxx\<PROJECTNAME>\.venv\Lib\site-packages\django\template\backends\django.py", line 33, in get_template
    return Template(self.engine.get_template(template_name), self)
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "c:\Users\xxxx\xxx\<PROJECTNAME>\.venv\Lib\site-packages\django\template\engine.py", line 177, in get_template
    template, origin = self.find_template(template_name)
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "c:\Users\xxxx\xxx\<PROJECTNAME>\.venv\Lib\site-packages\django\template\engine.py", line 159, in find_template
    template = loader.get_template(name, skip=skip)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "c:\Users\xxxx\xxx\<PROJECTNAME>\.venv\Lib\site-packages\django\template\loaders\cached.py", line 57, in get_template
    template = super().get_template(template_name, skip)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "c:\Users\xxxx\xxx\<PROJECTNAME>\.venv\Lib\site-packages\django\template\loaders\base.py", line 28, in get_template
    return Template(
           ^^^^^^^^^
  File "c:\Users\xxxx\xxx\<PROJECTNAME>\.venv\Lib\site-packages\django\template\base.py", line 154, in __init__
    self.nodelist = self.compile_nodelist()
                    ^^^^^^^^^^^^^^^^^^^^^^^
  File "c:\Users\xxxx\xxx\<PROJECTNAME>\.venv\Lib\site-packages\django\template\base.py", line 196, in compile_nodelist
    return parser.parse()
           ^^^^^^^^^^^^^^
  File "c:\Users\xxxx\xxx\<PROJECTNAME>\.venv\Lib\site-packages\django\template\base.py", line 510, in parse
    raise self.error(token, e)
  File "c:\Users\xxxx\xxx\<PROJECTNAME>\.venv\Lib\site-packages\django\template\base.py", line 508, in parse
    compiled_result = compile_func(self, token)
                      ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "c:\Users\xxxx\xxx\<PROJECTNAME>\.venv\Lib\site-packages\django\template\loader_tags.py", line 295, in do_extends
    nodelist = parser.parse()
               ^^^^^^^^^^^^^^
  File "c:\Users\xxxx\xxx\<PROJECTNAME>\.venv\Lib\site-packages\django\template\base.py", line 504, in parse
    self.invalid_block_tag(token, command, parse_until)
  File "c:\Users\xxxx\xxx\<PROJECTNAME>\.venv\Lib\site-packages\django\template\base.py", line 565, in invalid_block_tag
    raise self.error(
django.template.exceptions.TemplateSyntaxError: Invalid block tag on line 22: 'content'. Did you forget to register or load this tag?
[15/May/2024 17:04:27] "GET /favicon.ico HTTP/1.1" 500 59

My base.html is as follows:

#base.html
{% block content %} 
     
{% endblock content %}

This is my template tag:

#template.html
{% extends 'base.html' %}
{% block content %} 
 
{% endblock content %}

Why is Django having an issue with this?

2
  • Add corresponding web server and Django logs into the question Commented May 15 at 15:42
  • End of block shouldn't contain a block name. Just {% endblock %}. P.S. While we at it, I can understand you wanted to hide some private information, but notice "invalid block tag on line 22" while your templates are of 4 or 5 lines each, there is no line 22. Such (improper) editing greatly decreases the possibility someone would be able to help; never do that. Always make sure your posted code/config examples are coherent with your posted logs. Find time to re-run your edited out example. Maybe, you'll even pinpoint your problem yourself, without needing to wait for someone else. Commented May 20 at 10:31

0

You must log in to answer this question.

Browse other questions tagged .