DRF fields limiting
About
This package provides utils for Django Rest Framework API views and serializers for limiting fields returned in responses thus limiting size and complexity of database requests.
Install
pip install drf-fields-limiting
Usage
Inherit from LimitedFieldsView or LimitedFieldsViewSet and configure it to enable fields limiting.
View limits fields of serialized object in response with respect to Fields HTTP header.
If header is not present or is empty show all fields. Fields limiting works only in GET requests.
LIMITED_FIELDS_CONFIG holds map of field name - operation to perform on queryset (from fields_limiting.operations).
It should contains entries for all fields declared in serializer_class.
...
class MySerializer(LimitedFieldsSerializer, serializers.ModelSerializer):
class Meta:
model = MyModel
fields = (
'char_field',
'int_field',
'foreign',
)
...
class MyViewSet(LimitedFieldsViewSet, viewsets.ModelViewSet):
...
LIMITED_FIELDS_CONFIG = {
'char_field': Only('char_field'),
'int_field': Only('int_field'),
'foreign': SelectRelated('foreign'),
}
serializer_class = MySerializer
...
All available operations are in drf_fields_limiting.operations module.
Example GET query:
GET /api/v1/base/my/ HTTP/1.1
Authorization: Token h3r315myt0k3n
Accept: application/json
Content-Type: application/json
Fields: char_field,int_field
License
The DRF complete autocomplete package is licensed under the FreeBSD License.
Metadata
Release files for drf-fields-limiting 1.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| drf-fields-limiting-1.0.0.tar.gz | 6.4 kB | Without provenance | Details for drf-fields-limiting-1.0.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| drf_fields_limiting-1.0.0-py3-none-any.whl | Python 3 | none | any | Details for drf_fields_limiting-1.0.0-py3-none-any.whl |
Total release size: 15.3 kB
Release files / drf-fields-limiting-1.0.0.tar.gz
| Download URL | drf-fields-limiting-1.0.0.tar.gz |
|---|---|
| Size | 6.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
c0ff32bc5169130ef5a9c52cdea2fef65395f1a5e4184aac1d7a8b10f85b754d
|
|
BLAKE2b-256 checksum How to use checksums |
e2721b3db50ae7f8fa997a350ab19fc8d6a5cf3f6652d2be8e94eb6fab243c29
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.62.3 importlib-metadata/4.11.1 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.9.10
|
Release files / drf_fields_limiting-1.0.0-py3-none-any.whl
| Download URL | drf_fields_limiting-1.0.0-py3-none-any.whl |
|---|---|
| Size | 9.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
f4720f298b5ce980bb0343210e3e3637f5c2bfc045871c23384f5ccdace55c6d
|
|
BLAKE2b-256 checksum How to use checksums |
f18e05e7c0a5138c244fb564564cba72caa7eb91e61a799d62538e5489598538
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.62.3 importlib-metadata/4.11.1 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.9.10
|
Security for drf-fields-limiting 1.0.0
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.