Hey, Here's some sample code just from reading what you've provided.
from django.contrib.auth.models import User users_in_country = User.objects.filter(cUser__name="some_country_name") if bool(users_in_country): # Check to make sure there's at least one User in the Country for user in users: goal = GoalsinCountry.objects.create(gCountry=user.cUsers, name="Some Name", descr="Some Description") goal.save() # Possibly not needed, I'd have to run the code to check With that said, I'd recommend changing the naming conventions of your Model fields. For example: User - name - country Goals - name - description - country Country - name On Fri, Jun 22, 2012 at 11:28 AM, django noob <djangon...@gmail.com> wrote: > Bump! > > > > > > > On Monday, June 18, 2012 9:13:50 PM UTC+1, django noob wrote: >> >> Greetings Django Experts! >> >> Say for example i have the following on my models.py >> >> >> class Country(models.Model): >> name = models.CharField(max_length=**50) >> >> def __unicode__(self): >> return u'%s %s' % (self.name, self.ID) >> >> class Meta: >> verbose_name = 'Countries' >> >> class Users(models.Model): >> name = models.CharField(max_length=**50) >> cUsers = models.ForeignKey(Country) >> >> def __unicode__(self): >> return self.name >> >> class Meta: >> verbose_name = 'Users on a country' >> >> class GoalsinCountry(models.Model): >> gCountry = models.ForeignKey(Country) >> name = models.CharField(max_length=**50) >> descr = models.TextField(blank=True, null=True) >> >> def __unicode__(self): >> return self.name >> class Meta: >> verbose_name = 'Goals Topic' >> >> >> >> How would you configure this in GoalsinCountry to return only users in >> a particular country and save this to >> GoalsinCountry Table? >> >> if i use gCountry = models.ForeignKey(Users) >> I would get a list of all users, i am interested in fitering to users >> on a particular country?? >> >> Please advice >> >> Thank you >> > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To view this discussion on the web visit > https://groups.google.com/d/msg/django-users/-/6Ekb7926kzkJ. > > 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. > -- 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.