Skip to content

Commit

Permalink
Merge pull request #511 from adamchainz/patch-2
Browse files Browse the repository at this point in the history
README - add syntax highlighting
  • Loading branch information
Carlton Gibson committed Nov 2, 2016
2 parents 2bcc7cf + c602fbb commit abaa3bb
Showing 1 changed file with 18 additions and 8 deletions.
26 changes: 18 additions & 8 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 @@ -33,7 +37,9 @@ Usage
Django-filter can be used for generating interfaces similar to the Django
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::
filterset for it with the code:

.. code-block:: python
import django_filters
Expand All @@ -43,14 +49,18 @@ filterset for it with the code::
fields = ['name', 'price', 'manufacturer']
And then in your view you could do::
And then in your view you could do:

.. 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-block:: python
import django_filters
Expand All @@ -61,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

0 comments on commit abaa3bb

Please sign in to comment.