On Dec 6, 10:29 am, Malcolm Tredinnick <[EMAIL PROTECTED]> wrote: > On Wed, 2007-12-05 at 15:34 -0800, globophobe wrote: > Probably an easier question to answer if we could see the models > involved (and perhaps an English description of what you are wanting to > achieve). My gut feeling is that this is either as simple as you get or > else it should be possible to fold the exclude directly into the "cards" > queryset without having to do an explicit extra query. Which alternative > is possible depends on your model relationships. > > Regards, > Malcolm
Good point. class Stack(models.Model): title = models.CharField(max_length=100) description = models.TextField() def __unicode__(self): return self.title class Card(models.Model): stack = models.ForeignKey(Stack) front = models.TextField(core=True) back = models.TextField(core=True) class Meta: ordering = ['id'] def __unicode__(self): return self.id class Study(models.Model): user = models.ForeignKey(User) stack = models.ForeignKey(Stack) card = models.ForeignKey(Card) total_correct = models.IntegerField() total_incorrect = models.IntegerField() average_correct = models.FloatField() def __unicode__(self): return self.id Basically, the Study model is a record of a users study history for a card. It doesn't have a ForeignKey to a stack as I only want rows to be inserted after a study session i.e. I don't want to create a record for each card for each user, even if it may be necessary eventually, because the number of records in Study could quickly amount to the tens or hundreds of thousands. A session has 20 or so cards which are sourced first from the Study model and then from cards in the Stack that are not yet contained in the Study model per user in question. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---