Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

198
Visualizações
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 Respostas
Responde à pergunta

0

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

about 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda