Reputation: 362
Sheet_Table
id ref_id name data
1 10 A 9078
2 10 AAA 6789
3 12 C 345
Sheet Model have multiple Columns id,ref_id,name,data
Now i want to write this query in django
select data from Sheet_Table where ref_id=10
Here Model/Table name is Sheet_Table
Upvotes: 0
Views: 3326
Reputation: 2830
It's pretty explicitly stated in the django doc on queries that filter(foo=bar)
evaluates to a WHERE
clause. In your specific case, try this to get a list of just the data
elements (if your model is actually called Sheet_Table
?):
Sheet_Table.objects.filter(ref_id=10).values_list('data', flat=True)
or you can leave off the values_list
part if you want to iterate over the model objects (e.g., if you want to examine id
as well as data
).
Upvotes: 1