From 2ece1c1fff57f584631bdec92984797462065902 Mon Sep 17 00:00:00 2001 From: Carlton Gibson Date: Mon, 28 Nov 2016 15:46:51 +0100 Subject: [PATCH] Develop update (#574) * README - add syntax highlighting Easier to read * Fixes typo in FiterSet docs Adds the missing letter "t" to DateRangeFiler. --- README.rst | 22 +++++++++++++--------- docs/ref/filterset.txt | 2 +- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/README.rst b/README.rst index ebb6537..9990599 100644 --- a/README.rst +++ b/README.rst @@ -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 @@ -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 @@ -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 @@ -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 ------- diff --git a/docs/ref/filterset.txt b/docs/ref/filterset.txt index 409c07c..1753ec5 100644 --- a/docs/ref/filterset.txt +++ b/docs/ref/filterset.txt @@ -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)