You can achieve what you are looking for using the 
include<https://docs.djangoproject.com/en/3.0/ref/templates/builtins/#include> 
directive.

Just have your parent and child include the same block and use with… phrase to 
override variables within the included template.

Regards,
David


On 20201114, at 01:15, Tristania W 
<[email protected]<mailto:[email protected]>> wrote:

Is it possible to make one sub-template inherit a div with dynamic content from 
an upper level template?

For eg., Template2 extends Template1. Within Template1, there is a div XXX that 
depends on a variable {{ var1 }}. This variable is passed to the view def 
view1, which renders Template 1. When Template2 is rendered, this div XXX is 
not rendered, because of the dynamic content.

Is there a DRY (Don't Repeat Yourself) way to make this inheritance possible?

Thanks.

--
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to 
[email protected]<mailto:[email protected]>.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/497e48c4-3bd8-4f14-84df-b70146712e77n%40googlegroups.com<https://groups.google.com/d/msgid/django-users/497e48c4-3bd8-4f14-84df-b70146712e77n%40googlegroups.com?utm_medium=email&utm_source=footer>.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/7C8BEAD4-4B4F-4CA9-8168-8E7F8D4C144E%40uniquode.io.

Reply via email to