Monday, April 30, 2012

Re: kind of template introspection question.

On Mon, Apr 30, 2012 at 4:22 PM, Marc Aymerich <> wrote:
> Dear all,
> Each model of my application has an associated template. This template
> should be rendered each time that their context changes. So this is an
> example to clarify this cryptic explanation:
> class ModelA(models.Model):
>   ....
> class ModelB(models.Model):
>   a = models.ForeignKey(ModelA)
> class ModelC(models.Model):
>   ...
>   def get_a(self):
>         return ModelA.objects.get(whatever_field=self.whatever_other_field)
> Each of these models has a "related template", and specifically:
> 1) ModelB related template contains this tag: {{ modelb_object.a.some_field }}
> 2) and ModelC template has: {{ modelc_object.get_a() }}
> This means that ModelC related template should be rendered when saves
> (changes) are performed on ModelA and ModelB (because ModelC context
> depends on them)

Sorry I mess things up on this paragraph, I wanted to say:

This means that when changes are performed on ModelA: ModelB and
ModelC related templates should be rendered since their context
depends on ModelA.


You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to
To unsubscribe from this group, send email to
For more options, visit this group at

No comments:

Post a Comment