KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I have a Model with a Foreign Key of "Parent" class Item(models.Model): parent = models.ForeignKey(Parent) This is the FK model class Parent(models.Model): name = models.CharField(blank=True, max_length=100) def __unicode__(self): return str(self.name) I am trying to run a query that gets all Items with a parent of "xyz" I get nothing Item.objects.filter(parent="xyz") When I try: Item.objects.filter(parent.name="xyz") Or: Item.objects.filter(str(parent)="xyz") I get an error: SyntaxError: keyword can't be an expression What is the proper way to do this?
Tags (comma-separated)
Save Edits
Cancel