Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

287
Vistas
Reuse same "block" of html in multiple django templates

Currently, I have two html template that extends from a base.html:

page1.html:

{% extends 'dashboard/base.html' %}
{% block tittle %} Dashboard1 {% endblock %}
... code ...
Code_block_1
{% endblock %}

page2.html:

{% extends 'dashboard/base.html' %}
{% block tittle %} Dashboard2 {% endblock %}
... code ...
Code_block_1
{% endblock %}

Both html share the same Code_block_1.

I was thinking about about creating another html called Code_block_1.html to consolidate this repeating piece of code. Then, insert Code_block_1.html into page1.html and pag2.html. Django only lets you extend once. How do I get around this problem?

Thanks.

about 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

Simply create another HTML file called code_block_1.html and then inside both page1.html and page2.html use include like this:

<!-- page1.html -->

{% extends 'dashboard/base.html' %}
{% block tittle %} Dashboard1 {% endblock %}
... code ...
{% include 'code_block_1.html' %}
{% endblock %}


<!-- page2.html -->

{% extends 'dashboard/base.html' %}
{% block tittle %} Dashboard2 {% endblock %}
... code ...
{% include 'code_block_1.html' %}
{% endblock %}
about 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda