Skip to content

How can I get records with true only? #1371

Answered by saadmk11
thanksyouall asked this question in Q&A
Discussion options

You must be logged in to vote

If you want to filter only the records which have is_archive=True you can override the views get_queryset() method.
for example:

def get_queryset(self):
    return super().get_queryset().filter(is_archive=True)

Or you can override the filter_queryset() method of your filterset class.
for example:

def filter_queryset(self, queryset):
    return super().filter_queryset(queryset).filter(is_archive=True)

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@thanksyouall
Comment options

Answer selected by carltongibson
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants