Monday, April 30, 2012

kind of template introspection question.

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)

So for each template I can provide a list of "dependent models" but
I'll be very happy if this behaviour can be provided "automatically".
Unfortunatly I do not have any clue on how to do that.

Someone has an idea?

Thanks so much!!

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