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

Develop update #574

Merged
merged 6 commits into from
Nov 28, 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
22 changes: 13 additions & 9 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,15 @@ Requirements
Installation
------------

Install using pip::
Install using pip:

.. code-block:: sh

pip install django-filter

Or clone the repo and add to your PYTHONPATH::
Or clone the repo and add to your ``PYTHONPATH``:

.. code-block:: sh

git clone git@github.com:carltongibson/django-filter.git

Expand All @@ -35,7 +39,7 @@ admin's ``list_filter`` interface. It has an API very similar to Django's
``ModelForms``. For example, if you had a Product model you could have a
filterset for it with the code:

.. code:: python
.. code-block:: python

import django_filters

Expand All @@ -47,16 +51,16 @@ filterset for it with the code:

And then in your view you could do:

.. code:: python
.. code-block:: python

def product_list(request):
filter = ProductFilter(request.GET, queryset=Product.objects.all())
return render(request, 'my_app/template.html', {'filter': filter})

Django-filters additionally supports specifying FilterSet fields using a
dictionary to specify filters with lookup types:
Django-filters additionally supports specifying ``FilterSet`` fields using
a dictionary to specify filters with lookup types:

.. code:: python
.. code-block:: python

import django_filters

Expand All @@ -67,8 +71,8 @@ dictionary to specify filters with lookup types:
'price': ['exact', 'gte', 'lte'],
}

The filters will be available as 'name', 'name__icontains', 'price',
'price__gte', and 'price__lte' in the above example.
The filters will be available as ``'name'``, ``'name__icontains'``,
``'price'``, ``'price__gte'``, and ``'price__lte'`` in the above example.

Support
-------
Expand Down
2 changes: 1 addition & 1 deletion docs/ref/filterset.txt
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ filters for a model field, you can override ``filter_for_lookup()``. Ex::
def filter_for_lookup(cls, f, lookup_type):
# override date range lookups
if isinstance(f, models.DateField) and lookup_type == 'range':
return django_filters.DateRangeFiler, {}
return django_filters.DateRangeFilter, {}

# use default behavior otherwise
return super(ProductFilter, cls).filter_for_lookup(f, lookup_type)