Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Add URLFilter for URLField. #1479

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 5 additions & 0 deletions django_filters/filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
'TimeRangeFilter',
'TypedChoiceFilter',
'TypedMultipleChoiceFilter',
'URLFilter',
'UUIDFilter',
]

Expand Down Expand Up @@ -151,6 +152,10 @@ class CharFilter(Filter):
field_class = forms.CharField


class URLFilter(Filter):
field_class = forms.URLField


class BooleanFilter(Filter):
field_class = forms.NullBooleanField

Expand Down
9 changes: 9 additions & 0 deletions tests/test_filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
TimeFilter,
TimeRangeFilter,
TypedMultipleChoiceFilter,
URLFilter,
UUIDFilter
)
from tests.models import Book, User
Expand Down Expand Up @@ -181,6 +182,14 @@ def test_default_field(self):
self.assertIsInstance(field, forms.CharField)


class URLFilterTests(TestCase):

def test_default_field(self):
f = URLFilter()
field = f.field
self.assertIsInstance(field, forms.URLField)


class UUIDFilterTests(TestCase):

def test_default_field(self):
Expand Down