[Fixed]-Rearrange blocks in django template

1đź‘Ť

Django templates do not work that way.

Docs say: “Template inheritance allows you to build a base “skeleton” template that contains all the common elements of your site and defines blocks that child templates can override”. So child templates only provide info, the content of a block to parent. And that’s all. They do nothing with arrangement.

You need to make another base template and extend it to get another block order on a page.

👤chem1st

0đź‘Ť

I solved this by moving each block into its own template, then

{% include "foo.html" %}
{% include "bar.html" %}
{% include "baz.html" %}

in the order I needed.

Leave a comment