I am trying to filter a table in Django based on the value of a specific ForeignKey field.
For example, I have two models:
class Asset(models.Model): name = models.TextField(max_length=150) project = models.ForeignKey('Project') class Project(models.Model): name = models.TextField(max_length=150)
I would like to filter my list of assets based on the name of the respective project.
I am currently doing two queries:
project_list = Project.objects.filter(name__contains="Foo") asset_list = Asset.objects.filter(desc__contains=filter, project__in=project_list).order_by('desc')
I am wondering if there is a way to specify this kind of filtering in the main request?
django django-models django-queryset
Fraser Graham Dec 30 '09 at 17:59 2009-12-30 17:59
source share