Hi, veasna bunhor yazmış: > I have two models : > > class Individual(models.Model): > name = models.CharField(max_length=200) > * is_author = models.BooleanField()* > active = models.BooleanField(default=True) > ---------------------------------------------------------------------------------------------------- > class Book(models.Model): > title = models.CharField(max_length=200) > *authors = models.ManyToManyField(Individual, > related_name="author_for", blank=True, null=True)*
you used related_name for model so you should call format similar to author.author_for.all() Q: What is meaning of "related_name" and how we use it? A: http://docs.djangoproject.com/en/dev/topics/db/models/#be-careful-with-related-name > ------------------------------------------------------------------------------------------------------------------ > > Can i make the query to get all the books that is_author? > i have tried: > >>>authors = Individual.objects.filter(is_author=True).filter(active=True) > >>>for author in authors: > print author.name <http://author.name> > for book in author.book_set.all(): > print book.title > > > --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---