How can I get records with true only? #1371
-
I want to get records whose is_archive field is always true. How can I do this? I tried: But then I can filter by is_archive=False. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
@carltongibson can you help me please? |
Beta Was this translation helpful? Give feedback.
-
If you want to filter only the records which have def get_queryset(self):
return super().get_queryset().filter(is_archive=True) Or you can override the def filter_queryset(self, queryset):
return super().filter_queryset(queryset).filter(is_archive=True) |
Beta Was this translation helpful? Give feedback.
If you want to filter only the records which have
is_archive=True
you can override the viewsget_queryset()
method.for example:
Or you can override the
filter_queryset()
method of your filterset class.for example: