mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-06-24 15:33:17 +03:00
Docs tweak
This commit is contained in:
parent
8eadac39ad
commit
91eabd54bb
|
@ -199,8 +199,7 @@ This enables us to make queries like:
|
||||||
|
|
||||||
http://example.com/api/products?manufacturer__name=foo
|
http://example.com/api/products?manufacturer__name=foo
|
||||||
|
|
||||||
This is nice, but it shows underlying model structure in REST API, which may
|
This is nice, but it exposes the Django's double underscore convention as part of the API. If you instead want to explicitly name the filter argument you can instead explicitly include it on the `FilterSet` class:
|
||||||
be undesired, but you can use:
|
|
||||||
|
|
||||||
import django_filters
|
import django_filters
|
||||||
from myapp.models import Product
|
from myapp.models import Product
|
||||||
|
@ -208,7 +207,6 @@ be undesired, but you can use:
|
||||||
from rest_framework import generics
|
from rest_framework import generics
|
||||||
|
|
||||||
class ProductFilter(django_filters.FilterSet):
|
class ProductFilter(django_filters.FilterSet):
|
||||||
|
|
||||||
manufacturer = django_filters.CharFilter(name="manufacturer__name")
|
manufacturer = django_filters.CharFilter(name="manufacturer__name")
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
|
|
Loading…
Reference in New Issue
Block a user