Wednesday, July 4, 2012

Re: Inheriting template with a form into an existing template

On 3-7-2012 18:46, DF wrote:
> I have a simple note taking part of my application I'm trying to converge
> into one template. Currently, I have one template and view that renders and
> posts the form and another that displays the results. I'd like to
> amalgamate these into one where the form exists and the results are
> displayed on the same page.
>
> This seems to be something that be achieved with template inheritance,

Why? Sisters are family, but don't inherit from each other and this is a
sister relationship. The only thing they have in common is the stuff
surrounding the data. One has a form.as_p the other is a loop based on
different variable. You're going to end up with more if statements than
code saved.
What you can do, is create a shared parent that does the page_title,
headline and so on for you, so that you only have to provide the content
block. So this would be a base_notes.html which extends base.html and
has an empty content block.
--
Melvyn Sopacua


--
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

No comments:

Post a Comment