Monday, April 30, 2012

Re: kind of template introspection question.

On Mon, Apr 30, 2012 at 4:22 PM, Marc Aymerich <glicerinu@gmail.com> 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.


--
Marc

--
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