Integration package for using django-rest-framework with prestojs
Project description
Presto DRF
Integration package for using django-rest-framework with prestojs
Installation
pip install presto_drf
API
Mixins
SerializerOptInFieldsMixin
Regulates fields exposed on a Serializer by default & as requested based on query parameters or context.
- Pass 'include_fields' / 'opt_in_fields' thru query params or context to use.
- multiple fields can either be separated by comma eg,
/?include_fields=first_name,email&opt_in_fields=gait_recognition_prediction
- or passed in the traditional list fashion eg,
/?include_fields=first_name&include_fields=email&opt_in_fields=gait_recognition_prediction
- or mixed eg,
/?include_fields=first_name,email&include_fields=boo
- By default, all "fields" defined in serializer, minus those listed in "opt_in_fields" would be returned.
- If "include_fields" is supplied, only fields requested this way would be returned.
- If "opt_in_fields" is supplied, fields requested this way PLUS fields from #1 or #2 would be returned.
- Pinned fields are always returned (defaults to primary key)
Usage:
class UserSerializer(SerializerOptInFieldsMixin, ModelSerializer):
class Meta:
model = User
fields = (
"id",
"first_name",
"last_name",
"email",
"region",
"activated_at",
"is_staff",
)
# These fields only returned if explicitly requested
opt_in_only_fields = ["activated_at", "is_staff"]
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
presto_drf-0.0.1.tar.gz
(2.7 kB
view details)
Built Distribution
File details
Details for the file presto_drf-0.0.1.tar.gz
.
File metadata
- Download URL: presto_drf-0.0.1.tar.gz
- Upload date:
- Size: 2.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.23.0 setuptools/40.6.2 requests-toolbelt/0.9.1 tqdm/4.48.1 CPython/3.6.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6cd21dee7821fc09e11d173a174ec0a912d8797954b3e7e91c232e947bf980a4 |
|
MD5 | 490a819992c518762e35fd1741131d7b |
|
BLAKE2b-256 | 8738bbe76e7525b210016aa82ec2fd31adcfab028856fed90902ec7617ca12e4 |
File details
Details for the file presto_drf-0.0.1-py3-none-any.whl
.
File metadata
- Download URL: presto_drf-0.0.1-py3-none-any.whl
- Upload date:
- Size: 4.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.23.0 setuptools/40.6.2 requests-toolbelt/0.9.1 tqdm/4.48.1 CPython/3.6.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 24d3cd7963e8a0190193096ca92b110fd98977527f7f898bae3fed1c7301845b |
|
MD5 | ab0970e27f5ced2b44835a6278e26602 |
|
BLAKE2b-256 | 2bfcc36b4ba86c09a10bcfb55c9068d66cee9f09bd0c10555aec6f224254f73c |