restricted_fields package¶
Submodules¶
restricted_fields.mixins module¶
- class restricted_fields.mixins.RestrictedFieldsSerializerMixin[source]¶
Bases:
object
API Serializer mixin
This provides support for restricting serialized data to only a subset of fields using the
only
anddefer
query parameters.- Parameters
only (list) – Restricted to only a subset of fields (Include these fields).
defer (list) – Defer the listed fields (Exclude these fields).
Example:
Serialize only the id and name fields.
GET https://.../api/users/?only=id&only=name
{ "count":1, "next": "http://127.0.0.1:8000/api/users/?only=id&only=name&page=1", "previous":null, "results":[ { "id":1, "name": "Test" }, ... ], }
- DEFERRED_FIELDS_PARAM = 'defer'¶
- RESTRICTED_FIELDS_PARAM = 'only'¶
- property context¶
Module contents¶
Top-level package for drf-restricted-fields.
- class restricted_fields.RestrictedFieldsSerializerMixin[source]¶
Bases:
object
API Serializer mixin
This provides support for restricting serialized data to only a subset of fields using the
only
anddefer
query parameters.- Parameters
only (list) – Restricted to only a subset of fields (Include these fields).
defer (list) – Defer the listed fields (Exclude these fields).
Example:
Serialize only the id and name fields.
GET https://.../api/users/?only=id&only=name
{ "count":1, "next": "http://127.0.0.1:8000/api/users/?only=id&only=name&page=1", "previous":null, "results":[ { "id":1, "name": "Test" }, ... ], }
- DEFERRED_FIELDS_PARAM = 'defer'¶
- RESTRICTED_FIELDS_PARAM = 'only'¶
- property context¶