how to select resultset by foreignkey `s attribute

by newlifeon 2009-07-01T13:34:59+00:00

class company(models.Model):
on=models.BooleanField()
class work(models.Model):
company=models.ForeignKey
(company,related_name='vote_company',)
。。。。
。。。。
how can I get the works those company.on is true??
bow
--~--~---------~--~----~------------~-------~--~----~
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+unsubscribe@googlegroups.com
For more options, visit this group at http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Re: how to select resultset by foreignkey `s attribute

by Gabriel .on 2009-07-01T13:44:40+00:00.

2009/7/1 newlife :
>
> class company(models.Model):
> on=models.BooleanField()
> class work(models.Model):
> company=models.ForeignKey
> (company,related_name='vote_company',)
>
> 。。。。
> 。。。。
>
> how can I get the works those company.on is true??
work.objects.filter(company__on=True)
The django documentation is a good place to look at
(http://docs.djangoproject.com/en/dev/topics/db/queries/#lookups-that-span-relationships)
--
Kind Regards
--~--~---------~--~----~------------~-------~--~----~
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+unsubscribe@googlegroups.com
For more options, visit this group at http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---