I am using the customized mysql query i.e, (using more than one table with use of "JOIN" in the query) Then I got the Results. But now i want to refine the given result. How is it possible ?. kindly answer me if you know.
Asked
Active
Viewed 320 times
2 Answers
1
You can try use extra() to perform your custom SQL as it will return QuerySet that can be further filtered. If you are using raw(), you won't be able to do anything else with the result.
Here's a similar question addressing the problem: Django: filter a RawQuerySet
Community
- 1
- 1
Timmy O'Mahony
- 53,000
- 18
- 155
- 177
0
The result returned should be a query set with field names so try this
result = some_query...
result = result.filter(field_name__lte=value)
result = result.exclude(field_name='EXPIRED')
You can replace field_name with an actual field_name. Its all highlighted here.
But essentially when you have a queryset you can run filters or excludes on it to refine the queryset.
nialloc
- 805
- 7
- 17