Skip to main content

Downloads Latest Version Supported Python versions

QuerysetSerializer

This package adds a serializer to ensure all models in the serializers get properly prefetched or selected

installation

pip install queryset-serializer

Usage

Simply install the package into your project and import the serializer

from queryset_serializer import QuerySetSerializer

class MyModelSerializer(QuerySetSerializer):
    ... 
    class Meta:
        ...

In order to prefetch/select everything make sure all serializers used are of QuerySetSerializer

Note : You cannot mix restframework.serializer.ModelSerializer with this class (However all instance of ModelSerializer should be replaceable)

Config

configurations can be changed as following:

from queryset_serializer.serializers import Config
Config.meta_class.{setting} = {new_value}

these are the relevant settings :

  • prefetch_to_attr_prefix , What string will be used as prefix.
  • prefetch_listing , How the prefetch is done (Options: PrefetchToAttrSerializerList, PrefetchSerializerList)

prefetch_listing

there are 2 options for the prefetch_listing. (Located in queryset_serializer.serializers.model)

  • PrefetchToAttrSerializerList will prefetch/select relations and use the to_attr attribute of the Prefetch class
  • PrefetchSerializerList will only prefetch/select relations

This package by default makes use PrefetchToAttrSerializerList, The benefit of this is that the .all() calls on the relations are nog longer lazy.

This can significantly speed up performance especially on a queryset with a large amount of results or if there are a lot of child (queryset)serializer

This can also be turned off, and instead do a regular prefetch:

from queryset_serializer.serializers import Config
from queryset_serializer.serializers.model import PrefetchSerializerList
Config.meta_class.prefetch_listing = PrefetchSerializerList

Metadata

Release files for queryset-serializer 1.0.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for queryset-serializer 1.0.4
File Size Uploaded Provenance Actions
queryset-serializer-1.0.4.tar.gz 7.8 kB Without provenance Details for queryset-serializer-1.0.4.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for queryset-serializer 1.0.4
File Interpreter ABI Platform Actions
queryset_serializer-1.0.4-py3-none-any.whl Python 3 none any Details for queryset_serializer-1.0.4-py3-none-any.whl

Total release size: 17.6 kB

Release files / queryset-serializer-1.0.4.tar.gz

Download URL queryset-serializer-1.0.4.tar.gz
Size 7.8 kB
Tags Source
SHA-256 checksum
How to use checksums
235c8315a7c0b13e1cba5ddf6d7fee1a117598b27c5c2ef042a299b390349555
BLAKE2b-256 checksum
How to use checksums
3851ad887bcace3ab4784504cfc208b0d7bd57c7d275e6c878aab1b4c604ded7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/45.2.0 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.6.6

Release files / queryset_serializer-1.0.4-py3-none-any.whl

Download URL queryset_serializer-1.0.4-py3-none-any.whl
Size 9.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
1faf64548e36f17c0fcee0cde3897a2bf183dcbf0f50e702e8fa23edbc226669
BLAKE2b-256 checksum
How to use checksums
27bb98f9d7562ae94082b1798379c9c69b8e4b82109a9f3974254928d9d8fa09
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/45.2.0 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.6.6

Security for queryset-serializer 1.0.4

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page