[Answered ]-Does django support separating your templates into parts?

2👍

There are many good ways to do this.

You can use the builtin templatetage include for this. This template tag allows you to to use and reuse specific fragments of a template. This is usually most useful for mini templates that say represent a single model and will be used throughout the site. This can be especially useful if you combine it with the with templatetag to allow you to craft the context used in the included template

Alternatively just simply using block may give you the feel you’re looking for

Finally you can use custom inclusion templatetags (https://docs.djangoproject.com/en/1.4/howto/custom-template-tags/#inclusion-tags) to give you an even deeper level of control. These will allow you to render a subtemplate with a completely custom context.

👤John

0👍

That is what templatetags are for. You define a tag in a file called myapp/templatetags/mytags.py, then in your template do this

{% load mytags %}

{% navbar %} {% sidebar %}

The official documentation has plenty of information about this.

👤jcdyer

Leave a comment