Skip to content

Commit

Permalink
Develop update (carltongibson#574)
Browse files Browse the repository at this point in the history
* README - add syntax highlighting

Easier to read

* Fixes typo in FiterSet docs

Adds the missing letter "t" to DateRangeFiler.
  • Loading branch information
Carlton Gibson authored Nov 28, 2016
1 parent 75ede3b commit 2ece1c1
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 10 deletions.
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)

0 comments on commit 2ece1c1

Please sign in to comment.