Re: select_related and 1-to-many relations

2009-04-07 Thread Eric
Thanks, although that reverses the logic, and only lets me select the most recent for one table. The example is actually simplified, my User object example actually has multiple items associated with it, for example, I want to show a User, most recent Item, most recent LogEntry, etc. On Apr 7, 4:

Re: select_related and 1-to-many relations

2009-04-07 Thread Florian Strzelecki
Hm... something like that : http://docs.djangoproject.com/en/dev/topics/db/queries/#backwards-related-objects You can reverse a relationship, using "u.*att*_set". --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Djang

select_related and 1-to-many relations

2009-04-06 Thread Ceph
I have the following models: class User(models.Model): pass class Item(Models.Mode): created = models.DateTime(default=datetime.now) user = models.ForeignKey(User, related_name="items") class Meta: ordering = ("-created",) get_latest_by = "created" So a user can