On 11/27/07, Eratothene ([EMAIL PROTECTED]) wrote: > >Hi django users! > >I have two simple models: Blog and Article. >class Blog(models.Model): > title = models.CharField() > content = models.TextField() > user = models.ForeignKey(User) > >class Article(models.Model): > title = models.CharField() > content = models.TextField() > blog = models.ForeignKey(Blog) > > >I need to get all blogs that belong to certain user and are empty (do >not have any articles). I can't figure out how to make it with without >extra() method. > >Any ideas?
I'm still pretty new at this myself but I don't see any other answers yet so I figure a little info is better than naught. I'm sure others will join in with better descriptions than mine. Depending upon context, I think you'll need to either use the select_related() or _set() i.e. article.select_related() or article.blog_set() with a filter something like .filter(blog__content__isnull=True) Review the db docs with the above to get a _much_ better description of how they work and in which context. HTH Scott --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---