Friday, June 22, 2012

Re: Select * from users,country where country.id = users.id in Django using amin.contrib

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+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

No comments:

Post a Comment