# People who need to be reminded class Reminders (models.Model): userProfile = models.ForeignKey(UserProfile) groups = models.ManyToManyField(Groups, blank=True, null=True) campaigns = models.ManyToManyField(Campaigns, blank=True, null=True)
# Campaign that needs to be sent out to People class Campaigns (models.Model): userProfile = models.ForeignKey(UserProfile) groups = models.ManyToManyField(Groups, blank=True, null=True) # Groups of People class Groups (models.Model): userProfile = models.ForeignKey(UserProfile) name = models.CharField( maxlength=100 ) groups_hash = models.CharField( maxlength=16 ) description = models.CharField( maxlength=100 ) If I have a campaign object that has 3 groups in it. And I want to find all the reminder objects that are in those groups ... unless of course it's a campaign with no groups in it - in which case I'd like all the reminders associated with that campaign ? This is my attempt, the second reminders statement won't work. I'm wondering what the best way to go about a query like this would be ? # campaign object from db campaign = <campaign_object> groups_list = campaign.groups.all() # Are there groups ? if groups_list.count() > 0 : # find the reminders ?????? reminders = campaign.groups.reminders_set.all() else: reminders = Reminders.objects.get(campaigns=campaign) --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---