Tuesday, October 26, 2010

Query field across multiple django models

I want to create a "What's New" section that lists all of the database
changes in the last day. I've added an "updated" field to my models:

class Film(models.Model):
.
.
.
updated = models.DateTimeField(auto_now=True)

class Actor(models.Model):
.
.
.
updated = models.DateTimeField(auto_now=True)

Now I want to query across all of my models to get a date-sorted list
of the most recent changes. How do I query the "updated" field across
multiple models? Is this the most efficient way to achieve the primary
purpose?

What if I wanted to be more specific and list the actual field that
was altered within each model?

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