On Thu, 2011-10-06 at 23:31 -0700, Tsung-Hsien wrote: > class Item(models.Model): > name = models.CharField(max_length=250) > description = models.TextField() > > class Meta: > ordering = ["name"] > > def __unicode__(self): > return self.name > > class Photo(models.Model): > item = models.ForeignKey(Item) > title = models.CharField(max_length=100) > image = models.ImageField(upload_to="photos") > caption = models.CharField(max_length=250, blank=True > > ------------------------------------------------ > I have 2 items each include 10 pictures, if I write > Photo.objects.all(), then I get all 20 pictures. > How can I get the 10 pictures belong to each item? > I read the Django' documentation about Foreign Key and still have no > idea.
iteminstance.photo_set.all() -- regards Kenneth Gonsalves -- 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.