Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

187
Views
Why is {% block content %} causing server 500 error in Django?

I have been trying to use the Django template inheritance feature for my project Since I've added {% block content %}s I am now getting a server error 500 whenever I try to run the child template. The base template runs fine. I am quite sure it has something to do with the content blocks, but I'm not sure why as I don't repeat any names of blocks and everything on the child template is contained within a block. The console says two errors:

Failed to load resource: the server responded with a status of 404 (Not Found)

Failed to load resource: the server responded with a status of 500 (Internal Server Error)

Code goes like this:

Base.html

<!DOCTYPE html>

<style>
'My style'
</style>

<html lang='en'>
<head>
    <meta charset='UTF-8'
    {% block title %}
        webpage
    {% endblock %}
    <script>'Jquery reference'</script>
</head>

{% block script %}
    'empty'
{% endblock %}

<body>
<div id='navbar'>
    'My navbar'
</div>

<div id='main_content_block'>
    {% block content %}
        <h1>This is my base</h1>
    {% endblock %}
</div>

</body>
</html>


    

Home.html

{% extends 'main/base.html' %}

{% block title %}
<title>Home</title>
{% endblock %}

{% block script %}
'My javascript'
{% endblock %}

{% block content %}
'My content'
{% endblock %}

Thanks for your time

about 4 years ago · Santiago Trujillo
1 answers
Answer question

0

Django couldn't find base.html and including the absolute path instead of the relative fixed it.

about 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!