I want to retrieve a data where id=1 and flag=’D’ in Django. I would use WHERE with AND in SQL. How can I do it in Django? I tried:
File.objects.filter(user_id=1 AND flag='D')
But it doesn’t work.
And another thing, I can I update only one filed of the the database in Django i.e updating flag='D' to flag='F' with everything same.
This should get you all File that has user_id=1 and flag=’D’
For Updating a column you should use update on queryset
You can also do
print
q.queryto see the sql generated by Django ORM