On Mon, 2009-02-02 at 20:52 -0800, Alexiski wrote: > Hi all, > This is a difficulty related to me being new to Django/Python I > assume, so I hope you can forgive my ignorance and help me out :) > > I have 4 tables - User(overriding the user object), Copy, Query, > QueryClassification. The main tables are Copy and Query. There can be > many Queries for each Copy, so... > > Query has: > copy = models.ForeignKey(Copy) > classification = models.ManyToManyField(QueryClassification) > Copy has: > user = models.ForeignKey(User) > > > Basically it isn't displaying any of the fields from Query or > QueryClassification and I'm not quite sure how to reference the other > foreign tables in reference to a one-to-many field. Clearly I can > iterate through the Copy items, but I can't get it to print the > multiple Query items next to the appropriate Copy items.
Given a Copy instance, obj, you can access the related Query instances (in a template) as obj.query.all. So iterate over that to get all the instances you're after. 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 -~----------~----~----~----~------~----~------~--~---