Search code examples
pythondjangopartial

How to render partial with django?


I am working on a web project with Django and I have a list of objects displayed on the main column of my page. I want to make filters (like price filter, city...) of this objects on left. I would like to separate this two parts of code, with a special views method to render the left colum (filters) and an other one to render the central part.

How can I do that?


Solution

  • You can use the {% include %} template tag.

    Alternatively, you can create a custom template tag if the "partial" are used in multiple views and you don't want to explicitly insert extra context variables.