From 75ede3beddbba5ebb2a0693e7f4dfeb58dd5c0cb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Germ=C3=A1n=20Larra=C3=ADn?= Date: Sat, 26 Nov 2016 07:18:18 -0300 Subject: [PATCH] README: add syntax highlighting (#572) --- README.rst | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/README.rst b/README.rst index e5fe804..ebb6537 100644 --- a/README.rst +++ b/README.rst @@ -33,7 +33,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:: python import django_filters @@ -43,14 +45,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:: 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:: +dictionary to specify filters with lookup types: + +.. code:: python import django_filters