Tuesday, July 29, 2014

Re: Compositional Templates Django

On Tue, Jul 29, 2014 at 9:41 AM, Secret <secretmapper16@gmail.com> wrote:
> What is the best way to create modular templates?
>
> For example, if I have something like this:
>
> #base file:
> {header}
> {block content}
> {footer}
>
> #main file:
> {extends base}
> {block content definition}
>
> #product file:
> {extends base}
> {block content definition}
>
> This is the django way from what I understand - filling in the blanks.
>
> Now, my question is what if I needed a page like this:
>
> {header}
> {main}
> {product}
> {footer}
>
> Basically, the main, and product are both inside the base file. I could try
> a deep inherit (a page that has main, which then consecutively loads
> product) but that does not work since the files both define 'content', and
> that is not possible in Django
>

If product is a specialisation of main, then it should extend main and
not base. If it is not, I do not understand the question.

It is common to define your base page style, without any content
layout or menu system at all, extend that to add basic layout and
menu, extend *that* to add a specific layout style, and then extend
that for each page in that style that has specific template needs.

Cheers

Tom

--
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 django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAFHbX1LM_e2LLq4OAE0naj44ZKMJFzsLoEHCZE38wxEjD_r7Rg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment