On Mon, 2009-03-09 at 18:04 -0700, Mario Zorz wrote: > Hi all > > Thanks in advance to whomever reads this :) > > Is it possible in a django view, to take objects from 2 different > models, which are related one to the other through a ForeignKey > (primary key of one model is foreign key in the other model), make > something similar to an SQL JOIN and have the collection of these > joined instances passed to the template through the render_to_response > shortcut? I need to do this specifically to show fields from both > models in the same template/view.
This is exactly the situation covered by the tutorial ([1]), where the Choice model is relate to the Poll model by a ForeignKey. Displaying polls and related choices is covered in part 3, the models are set up in part 1. [1] http://docs.djangoproject.com/en/dev/intro/tutorial01/ You didn't skip doing the tutorial did you? Regards, Malcolm > --~--~---------~--~----~------------~-------~--~----~ 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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---