drf_auto_endpoint
drf_auto_endpoint
's main feature is to provide a router on which you can register Model
's directly.
Not unlike Model
's directly in Django admin.'
Registering a Model
on the router implicitly creates an Endpoint
which in turn uses
factory methods to create a ModelViewSet
and a ModelSerializer
corresponding to the registered Model
.
This is great for prototyping but as your application progresses you'll probably want to customize those endpoints. Some customization can be done passing parameters directly to the router when registering models.
read_only
: boolean, indicates whether this endpoint should be read_only or notfields
: a list of fields that will be available on the endpointbase_serializer
: a base serializer class to use instead of the default (ModelSerialier
)serializer
: a custom serializer call that will be used to create the endpoint.include_str
: a boolean indicating whether or not__str__
should be added to the serialier's fields listfieldsets
: a tuple containing the list of fields. metadata.filter_fields
: a tuple containing a list of fields on which the endpoint will accept filteringsearch_fields
: a tuple containing a list of fields on which the endpoint will accept searching (text fields only)ordering_fields
: a tuple containing a list of fields on which the endpoint will accept orderingpage_size
: the number of records to render at once (automatically activates pagination)permission_classes
: a tuple containing the list of DRF permission classes to useurl
: the base url for the viewsetviewset
: the viewset class to use instead of the auto-generated onebase_viewset
: a base viewset class to use instead of the defaults (ModelViewSet
orReadOnlyModelViewSet
)fields_annotation
: a dictionary with fieldnames as keys and annotation dictionaries as values Right now, the only annotation type which are supported areplaceholder
andhelp
list_me
: a Boolean value indicating whether or not that endpoint should be listed in the APIRoot's metadata
Now passing too many parameters to the router in your urls.py
is usually not the best practice and when
your endpoints start getting more complex, we recommend using a custom Endpoint
class