On Oct 8, 12:22 am, J <[EMAIL PROTECTED]> wrote: > How would I include the "date" field from the first model ("Post") in > the queryset created from "PostI18N", using something similar to: > > queryset = > PostI18N.objects.filter(lang=get_language()).order_by('post__date') > > Would that date field already be included? How would I access it from > the template?
That query will work fine. In the background it will join the two tables for the purposes of filtering your result set, but will not select any data from the Post table. You can still do this in your template (if post_i18n is a member of the above queryset): {{ post_i18n.post.date }} But each time you do that it will generate a new database query to look up the Post info. To avoid the extra queries, you'd use the select_related() method on your queryset: queryset = PostI18N.objects.filter(lang=get_language()).order_by('post__date').select_related('post') This will select all the data from both tables initially, so a single query gets you everything you need. Carl --~--~---------~--~----~------------~-------~--~----~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---