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

lookup_type is deprecated in favor of lookup_expr #4259

Merged
merged 1 commit into from
Jul 13, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions docs/api-guide/filtering.md
Original file line number Diff line number Diff line change
Expand Up @@ -178,8 +178,8 @@ For more advanced filtering requirements you can specify a `FilterSet` class tha
from rest_framework import generics

class ProductFilter(filters.FilterSet):
min_price = django_filters.NumberFilter(name="price", lookup_type='gte')
max_price = django_filters.NumberFilter(name="price", lookup_type='lte')
min_price = django_filters.NumberFilter(name="price", lookup_expr='gte')
max_price = django_filters.NumberFilter(name="price", lookup_expr='lte')
class Meta:
model = Product
fields = ['category', 'in_stock', 'min_price', 'max_price']
Expand Down
8 changes: 4 additions & 4 deletions tests/test_filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ class FilterFieldsRootView(generics.ListCreateAPIView):

# These class are used to test a filter class.
class SeveralFieldsFilter(django_filters.FilterSet):
text = django_filters.CharFilter(lookup_type='icontains')
decimal = django_filters.NumberFilter(lookup_type='lt')
date = django_filters.DateFilter(lookup_type='gt')
text = django_filters.CharFilter(lookup_expr='icontains')
decimal = django_filters.NumberFilter(lookup_expr='lt')
date = django_filters.DateFilter(lookup_expr='gt')

class Meta:
model = FilterableItem
Expand All @@ -53,7 +53,7 @@ class FilterClassRootView(generics.ListCreateAPIView):

# These classes are used to test a misconfigured filter class.
class MisconfiguredFilter(django_filters.FilterSet):
text = django_filters.CharFilter(lookup_type='icontains')
text = django_filters.CharFilter(lookup_expr='icontains')

class Meta:
model = BasicModel
Expand Down
6 changes: 3 additions & 3 deletions tests/test_model_serializer.py
Original file line number Diff line number Diff line change
Expand Up @@ -377,9 +377,9 @@ class Meta:

s = TestSerializer(data={'address': 'not an ip address'})
self.assertFalse(s.is_valid())
self.assertEquals(1, len(s.errors['address']),
'Unexpected number of validation errors: '
'{0}'.format(s.errors))
self.assertEqual(1, len(s.errors['address']),
'Unexpected number of validation errors: '
'{0}'.format(s.errors))


# Tests for relational field mappings.
Expand Down
6 changes: 3 additions & 3 deletions tests/test_renderers.py
Original file line number Diff line number Diff line change
Expand Up @@ -286,14 +286,14 @@ def test_render_queryset_values(self):
qs = DummyTestModel.objects.values('id', 'name')
ret = JSONRenderer().render(qs)
data = json.loads(ret.decode('utf-8'))
self.assertEquals(data, [{'id': o.id, 'name': o.name}])
self.assertEqual(data, [{'id': o.id, 'name': o.name}])

def test_render_queryset_values_list(self):
o = DummyTestModel.objects.create(name='dummy')
qs = DummyTestModel.objects.values_list('id', 'name')
ret = JSONRenderer().render(qs)
data = json.loads(ret.decode('utf-8'))
self.assertEquals(data, [[o.id, o.name]])
self.assertEqual(data, [[o.id, o.name]])

def test_render_dict_abc_obj(self):
class Dict(MutableMapping):
Expand Down Expand Up @@ -323,7 +323,7 @@ def keys(self):
x[2] = 3
ret = JSONRenderer().render(x)
data = json.loads(ret.decode('utf-8'))
self.assertEquals(data, {'key': 'string value', '2': 3})
self.assertEqual(data, {'key': 'string value', '2': 3})

def test_render_obj_with_getitem(self):
class DictLike(object):
Expand Down
4 changes: 2 additions & 2 deletions tests/test_versioning.py
Original file line number Diff line number Diff line change
Expand Up @@ -298,8 +298,8 @@ class TestNamespaceVersioningHyperlinkedRelatedFieldScheme(URLPatternsTestCase):
]

urlpatterns = [
url(r'^v1/', include(included, namespace='v1')),
url(r'^v2/', include(included, namespace='v2')),
url(r'^v1/', include(included, namespace='v1', app_name='restframeworkv1')),
url(r'^v2/', include(included, namespace='v2', app_name='restframeworkv2')),
url(r'^non-api/(?P<pk>\d+)/$', dummy_pk_view, name='non-api-view')
]

Expand Down
4 changes: 2 additions & 2 deletions tests/test_write_only_fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@ def write_only_fields_are_present_on_input(self):
}
serializer = self.Serializer(data=data)
self.assertTrue(serializer.is_valid())
self.assertEquals(serializer.validated_data, data)
self.assertEqual(serializer.validated_data, data)

def write_only_fields_are_not_present_on_output(self):
instance = {
'email': '[email protected]',
'password': '123'
}
serializer = self.Serializer(instance)
self.assertEquals(serializer.data, {'email': '[email protected]'})
self.assertEqual(serializer.data, {'email': '[email protected]'})