Skip to content

Commit c3d92a2

Browse files
authored
Merge branch 'main' into python-support-315
2 parents 4a92b5f + 107d033 commit c3d92a2

6 files changed

Lines changed: 57 additions & 4 deletions

File tree

‎.github/dependabot.yml‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,3 +45,14 @@ updates:
4545
interval: weekly
4646
cooldown:
4747
default-days: 7
48+
49+
- package-ecosystem: "pre-commit"
50+
directory: "/"
51+
groups:
52+
pre-commit:
53+
patterns:
54+
- "*"
55+
schedule:
56+
interval: weekly
57+
cooldown:
58+
default-days: 7

‎.github/workflows/main.yml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ jobs:
7373
tox -e base,dist,docs
7474
7575
- name: Upload coverage
76-
uses: codecov/codecov-action@v7.0.0
76+
uses: codecov/codecov-action@v7.1.0
7777
with:
7878
env_vars: TOXENV,DJANGO
7979

‎.pre-commit-config.yaml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ repos:
2525
hooks:
2626
- id: blacken-docs
2727
additional_dependencies:
28-
- black==26.1.0
28+
- black==26.5.1
2929
- repo: https://github.com/codespell-project/codespell
3030
# Configuration for codespell is in pyproject.toml
3131
rev: v2.4.3

‎docs/api-guide/filtering.md‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -374,6 +374,11 @@ The [djangorestframework-word-filter][django-rest-framework-word-search-filter]
374374

375375
[drf-url-filter][drf-url-filter] is a simple Django app to apply filters on drf `ModelViewSet`'s `Queryset` in a clean, simple and configurable way. It also supports validations on incoming query params and their values. A beautiful python package `Voluptuous` is being used for validations on the incoming query parameters. The best part about voluptuous is you can define your own validations as per your query params requirements.
376376

377+
### rest-filters
378+
379+
[rest-filters][rest-filters] is a modern, typed replacement for `django-filter` that uses DRF's serializer API. In addition to basic filtering, rest-filters supports filter groups, nested filters and filter defaults. It also includes a constraint system to perform validation across filters with ease. Since it uses the serializer API, you can use your existing serializers or serializer fields to parse query parameters.
380+
381+
377382
[cite]: https://docs.djangoproject.com/en/stable/topics/db/queries/#retrieving-specific-objects-with-filters
378383
[django-filter-docs]: https://django-filter.readthedocs.io/en/latest/index.html
379384
[django-filter-drf-docs]: https://django-filter.readthedocs.io/en/latest/guide/rest_framework.html
@@ -382,6 +387,7 @@ The [djangorestframework-word-filter][django-rest-framework-word-search-filter]
382387
[django-rest-framework-word-search-filter]: https://github.com/trollknurr/django-rest-framework-word-search-filter
383388
[django-url-filter]: https://github.com/miki725/django-url-filter
384389
[drf-url-filter]: https://github.com/manjitkumar/drf-url-filters
390+
[rest-filters]: https://github.com/realsuayip/rest-filters
385391
[HStoreField]: https://docs.djangoproject.com/en/stable/ref/contrib/postgres/fields/#hstorefield
386392
[JSONField]: https://docs.djangoproject.com/en/stable/ref/models/fields/#django.db.models.JSONField
387393
[postgres-search]: https://docs.djangoproject.com/en/stable/ref/contrib/postgres/search/

‎pyproject.toml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ djangomain = [ "django @ https://github.com/django/django/archive/main.tar.gz" ]
6565
optional = [
6666
# Optional packages which may be used with REST framework.
6767
"django-filter",
68-
"django-guardian>=2.4.0,<3.5",
68+
"django-guardian>=2.4.0,<3.6",
6969
"inflection==0.5.1",
7070
"legacy-cgi; python_version>='3.13'",
7171
"markdown>=3.3.7",

‎tests/test_model_serializer.py‎

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
import tempfile
1414

1515
import pytest
16-
from django.core.exceptions import ImproperlyConfigured
16+
from django.core.exceptions import ImproperlyConfigured, ValidationError
1717
from django.core.serializers.json import DjangoJSONEncoder
1818
from django.core.validators import (
1919
MaxLengthValidator, MaxValueValidator, MinLengthValidator,
@@ -1498,3 +1498,39 @@ class Meta:
14981498
serializer.save()
14991499

15001500
self.assertEqual(instance.char_field, 'value changed by signal')
1501+
1502+
1503+
class OverflowModel(models.Model):
1504+
value = models.IntegerField(unique=True, validators=[
1505+
MaxValueValidator(9223372036854775807),
1506+
])
1507+
1508+
1509+
class Issue7134Test(TestCase):
1510+
1511+
def test_model(self):
1512+
"""
1513+
Assert that Django can validate the overflow model.
1514+
"""
1515+
with self.assertRaises(ValidationError):
1516+
OverflowModel(value=9223372036854775808).full_clean()
1517+
1518+
def test_serializer(self):
1519+
class TestSerializer(serializers.ModelSerializer):
1520+
class Meta:
1521+
model = OverflowModel
1522+
fields = '__all__'
1523+
1524+
def validate_value(self, value):
1525+
assert False
1526+
1527+
serializer = TestSerializer(data={'value': 9223372036854775808})
1528+
1529+
with self.assertRaises(serializers.ValidationError) as ctx:
1530+
serializer.is_valid(raise_exception=True)
1531+
1532+
# Check that the error code of the validation error
1533+
self.assertEqual(
1534+
[error.code for error in ctx.exception.detail['value']],
1535+
['max_value'],
1536+
)

0 commit comments

Comments
 (0)