Reputation: 103
I would like to know how can we run queries from Django Model if we want to retrieve more than one value for same field
For Example This is my Model
class Ball(models.Model):
Ballname = models.CharField(max_length=8,primary_key=True)
Ballcolor = models.CharField(max_length=10)
I am trying to get All Balls of Red and White Color
dataset = data.filter(Ballcolor="red", Ballcolor ="white")
But I get an error saying same field cant be used more than once. How do I get about getting this data ?
Upvotes: 0
Views: 27
Reputation: 5669
You can do it with in
dataset = data.filter(Ballcolor__in=['red','white'])
Upvotes: 2