Merge pull request #573 from carltongibson/develop

Version 1.0.1 release
This commit is contained in:
Carlton Gibson 2016-11-28 16:02:13 +01:00 committed by GitHub
commit c906cf3149
11 changed files with 81 additions and 30 deletions

View File

@ -1,5 +1,5 @@
[bumpversion]
current_version = 1.0.0
current_version = 1.0.1
commit = False
tag = False
parse = (?P<major>\d+)\.(?P<minor>\d+)\.(?P<patch>\d+)(\-(?P<release>[a-z]+))?

View File

@ -1,3 +1,13 @@
Version 1.0.1 (2016-11-28)
--------------------------
Small release to ease compatibility with DRF:
* #568 Adds ``rest_framework`` to the ``django_filters`` namespace to allow single
``import django_filters` usage.
* A number of small updates to the docs
Version 1.0 (2016-11-17)
------------------------
@ -6,7 +16,7 @@ This release removes all the deprecated code from 0.14 and 0.15 for 1.0 #480.
Please see the `Migration Notes`__ for details of how to migrate.
Stick with 0.15.3 if you're not ready to update.
__ https://github.com/carltongibson/django-filter/blob/develop/docs/migration.txt
__ https://github.com/carltongibson/django-filter/blob/1.0.0/docs/guide/migration.txt
The release includes a number of small fixes and documentation updates.
@ -70,7 +80,7 @@ Summary: Highly Recommended, but take a moment to ensure everything still works.
* Hardened all deprecations for 1.0. Please do see the `Migration Notes`__
__ https://github.com/carltongibson/django-filter/blob/develop/docs/migration.txt
__ https://github.com/carltongibson/django-filter/blob/1.0.0/docs/guide/migration.txt

View File

@ -1,7 +1,11 @@
.PHONY: deps, test
.PHONY: deps, test, clean
deps:
pip install -r ./requirements/test.txt
test:
./runtests.py
./runtests.py
clean:
rm -r build dist django_filter.egg-info

View File

@ -80,5 +80,5 @@ Support
If you have questions about usage or development you can join the
`mailing list`_.
.. _`read the docs`: https://django-filter.readthedocs.io/en/latest/
.. _`read the docs`: https://django-filter.readthedocs.io/en/develop/
.. _`mailing list`: http://groups.google.com/group/django-filter

View File

@ -4,7 +4,14 @@ from .constants import STRICTNESS
from .filterset import FilterSet
from .filters import *
__version__ = '1.0.0'
# We make the `rest_framework` module available without an additional import.
# If DRF is not installed we simply set None.
try:
from . import rest_framework
except ImportError:
rest_framework = None
__version__ = '1.0.1'
def parse_version(version):

View File

@ -241,7 +241,7 @@ class BaseFilterSet(object):
assert not (fields is None and exclude is None), \
"Setting 'Meta.model' without either 'Meta.fields' or 'Meta.exclude' " \
"has been deprecated since 0.15.0 and is now disallowed. Add an explicit" \
"has been deprecated since 0.15.0 and is now disallowed. Add an explicit " \
"'Meta.fields' or 'Meta.exclude' to the %s class." % cls.__name__
# Setting exclude with no fields implies all other fields.
@ -327,8 +327,8 @@ class BaseFilterSet(object):
assert filter_class is not None, (
"%s resolved field '%s' with '%s' lookup to an unrecognized field "
"type %s. Try adding an override to 'filter_overrides'. See: "
"https://django-filter.readthedocs.io/en/latest/usage.html#overriding-default-filters"
"type %s. Try adding an override to 'Meta.filter_overrides'. See: "
"https://django-filter.readthedocs.io/en/develop/ref/filterset.html#customise-filter-generation-with-filter-overrides"
) % (cls.__name__, name, lookup_expr, f.__class__.__name__)
return filter_class(**default)

View File

@ -22,7 +22,7 @@ from .exceptions import FieldLookupError
def deprecate(msg, level_modifier=0):
warnings.warn(
"%s See: https://django-filter.readthedocs.io/en/latest/migration.html" % msg,
"%s See: https://django-filter.readthedocs.io/en/develop/migration.html" % msg,
DeprecationWarning, stacklevel=3 + level_modifier)

View File

@ -48,9 +48,9 @@ copyright = u'2013, Alex Gaynor and others.'
# built documents.
#
# The short X.Y version.
version = '1.0.0'
version = '1.0.1'
# The full version, including alpha/beta/rc tags.
release = '1.0.0'
release = '1.0.1'
# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.

View File

@ -135,23 +135,9 @@ Overriding default filters
Like ``django.contrib.admin.ModelAdmin``, it is possible to override
default filters for all the models fields of the same kind using
``filter_overrides``::
``filter_overrides`` on the ``Meta`` class::
class ProductFilter(django_filters.FilterSet):
filter_overrides = {
models.CharField: {
'filter_class': django_filters.CharFilter,
'extra': lambda f: {
'lookup_expr': 'icontains',
},
},
models.BooleanField: {
'filter_class': django_filters.BooleanFilter,
'extra': lambda f: {
'widget': forms.CheckboxInput,
},
},
}
class Meta:
model = Product
@ -159,6 +145,20 @@ default filters for all the models fields of the same kind using
'name': ['exact'],
'release_date': ['isnull'],
}
filter_overrides = {
models.CharField: {
'filter_class': django_filters.CharFilter,
'extra': lambda f: {
'lookup_expr': 'icontains',
},
},
models.BooleanField: {
'filter_class': django_filters.BooleanFilter,
'extra': lambda f: {
'widget': forms.CheckboxInput,
},
},
}
Request-based filtering

View File

@ -12,7 +12,7 @@ Meta options
- :ref:`exclude <exclude>`
- :ref:`form <form>`
- :ref:`together <together>`
- filter_overrides
- :ref:`filter_overrides <filter_overrides>`
- :ref:`strict <strict>`
@ -120,6 +120,36 @@ field set must either be all or none present in the request for
fields = ['price', 'release_date', 'rating']
together = ['rating', 'price']
.. _filter_overrides:
Customise filter generation with ``filter_overrides``
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The inner ``Meta`` class also takes an optional ``filter_overrides`` argument.
This is a map of model fields to filter classes with options::
class ProductFilter(django_filters.FilterSet):
class Meta:
model = Product
fields = ['name', 'release_date']
filter_overrides = {
models.CharField: {
'filter_class': django_filters.CharFilter,
'extra': lambda f: {
'lookup_expr': 'icontains',
},
},
models.BooleanField: {
'filter_class': django_filters.BooleanFilter,
'extra': lambda f: {
'widget': forms.CheckboxInput,
},
},
}
.. _strict:
``strict``

View File

@ -6,7 +6,7 @@ f = open('README.rst')
readme = f.read()
f.close()
version = '1.0.0'
version = '1.0.1'
if sys.argv[-1] == 'publish':
if os.system("pip freeze | grep wheel"):