55 lines
1.7 KiB
Plaintext
55 lines
1.7 KiB
Plaintext
Migrating to 1.0
|
|
================
|
|
|
|
The 1.0 release of django-filter introduces several API changes and refinements
|
|
that break forwards compatibility. Below is a list of deprecations and
|
|
instructions on how to migrate to the 1.0 release. A forwards-compatible 0.15
|
|
release has also been created to help with migration. It is compatible with
|
|
both the existing and new APIs and will raise warnings for deprecated behavior.
|
|
|
|
|
|
QuerySet methods are no longer proxied
|
|
--------------------------------------
|
|
Details: https://github.com/carltongibson/django-filter/pull/440
|
|
|
|
The ``__iter__()``, ``__len__()``, ``__getitem__()``, ``count()`` methods are
|
|
no longer proxied from the queryset. To fix this, call the methods on the
|
|
``.qs`` property itself.
|
|
|
|
.. code-block:: python
|
|
|
|
f = UserFilter(request.GET, queryset=User.objects.all())
|
|
|
|
# 0.x
|
|
for obj in f:
|
|
...
|
|
|
|
# 1.0
|
|
for obj in f.qs:
|
|
...
|
|
|
|
|
|
Filters no longer autogenerated when Meta.fields is not specified
|
|
-----------------------------------------------------------------
|
|
Details: https://github.com/carltongibson/django-filter/pull/450
|
|
|
|
FilterSets had an undocumented behavior of autogenerating filters for all
|
|
model fields when either ``Meta.fields`` was not specified or when set to
|
|
``None``. This can lead to potentially unsafe data or schema exposure and
|
|
has been deprecated in favor of explicitly setting ``Meta.fields`` to the
|
|
``'__all__'`` special value. You may also blacklist fields by setting
|
|
the ``Meta.exclude`` attribute.
|
|
|
|
.. code-block:: python
|
|
|
|
class UserFilter(FilterSet):
|
|
class Meta:
|
|
model = User
|
|
fields = '__all__'
|
|
|
|
# or
|
|
class UserFilter(FilterSet):
|
|
class Meta:
|
|
model = User
|
|
exclude = ['password']
|