Skip to main content

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


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.2.tar.gz (4.3 kB view details)

Uploaded Source

Built Distribution

presto_drf-0.0.2-py3-none-any.whl (6.2 kB view details)

Uploaded Python 3

File details

Details for the file presto_drf-0.0.2.tar.gz.

File metadata

  • Download URL: presto_drf-0.0.2.tar.gz
  • Upload date:
  • Size: 4.3 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

Hashes for presto_drf-0.0.2.tar.gz
Algorithm Hash digest
SHA256 ba2ff9972f04037f8abec56f7f4d45e9a5a974600ebb6f17fd114ff02379cd01
MD5 16b32488e986e83ee02cf11160ed5713
BLAKE2b-256 bdef88630bb5f683beced31fc68da6da34b03caf1a2f5e874598bc27bbc2a03f

See more details on using hashes here.

File details

Details for the file presto_drf-0.0.2-py3-none-any.whl.

File metadata

  • Download URL: presto_drf-0.0.2-py3-none-any.whl
  • Upload date:
  • Size: 6.2 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

Hashes for presto_drf-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 ddc3d59878ba96217e6711fc5dbbbfac69f345cc8c057b40baa3a566f331dad4
MD5 0e3b8bcb83210957ddcaa7b2a68c89fa
BLAKE2b-256 5721e60f80c1ce73c2ef2376ed8d5785d32345cfae7eea68312e0ca61a762bae

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page