Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

fix field_name of BooleanFilter #1441

Conversation

mayukorin
Copy link

First, please see the Issue #1440.
This is about #1440 "1. published field exists in Book model".
I think it would be better to change it as following.

# published = BooleanFilter(field_name='published_on', method='filter_published')
published = BooleanFilter(field_name='published', method='filter_published')

Modified code was tested with following change on the test section of #.

# views.py
from django_filters import BooleanFilter
from django_filters import rest_framework as filters
from rest_framework import generics
from .serializers import BookSerializer
from .models import Book


class F(filters.FilterSet):

    # published = BooleanFilter(field_name="published_on", method="filter_published")
    published = BooleanFilter(field_name="published", method="filter_published")
   ....

The result was successful.

Creating test database for alias 'default'...
System check identified no issues (0 silenced).
published_on__isnull
.
----------------------------------------------------------------------
Ran 1 test in 0.469s

OK
Destroying test database for alias 'default'...

Copy link
Owner

@carltongibson carltongibson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this change is necessary. Thanks.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants