Skip to content

Commit

Permalink
Merge pull request #573 from carltongibson/develop
Browse files Browse the repository at this point in the history
Version 1.0.1 release
  • Loading branch information
Carlton Gibson committed Nov 28, 2016
2 parents f5b2d63 + 6eff47f commit c906cf3
Show file tree
Hide file tree
Showing 11 changed files with 81 additions and 30 deletions.
2 changes: 1 addition & 1 deletion .bumpversion.cfg
Original file line number Diff line number Diff line change
@@ -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]+))?
Expand Down
14 changes: 12 additions & 2 deletions CHANGES.rst
Original file line number Diff line number Diff line change
@@ -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)
------------------------
Expand All @@ -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.
Expand Down Expand Up @@ -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



Expand Down
8 changes: 6 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -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

2 changes: 1 addition & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
9 changes: 8 additions & 1 deletion django_filters/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,14 @@
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):
Expand Down
6 changes: 3 additions & 3 deletions django_filters/filterset.py
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ def get_fields(cls):

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.
Expand Down Expand Up @@ -327,8 +327,8 @@ def filter_for_field(cls, f, name, lookup_expr='exact'):

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)
Expand Down
2 changes: 1 addition & 1 deletion django_filters/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

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)


Expand Down
4 changes: 2 additions & 2 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,9 @@
# 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.
Expand Down
30 changes: 15 additions & 15 deletions docs/guide/usage.txt
Original file line number Diff line number Diff line change
Expand Up @@ -135,30 +135,30 @@ 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
fields = {
'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
Expand Down
32 changes: 31 additions & 1 deletion docs/ref/filterset.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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>`


Expand Down Expand Up @@ -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``
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
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"):
Expand Down

0 comments on commit c906cf3

Please sign in to comment.