Django REST Envelop
Turn the ViewSet list endpoints to return an object rather than a list directly.
Installation
From PYPi using pip:
pip install django-rest-envelope
Usage
In your viewset views, you can use the ListEnvelopeMixin along with another mixin that defines the list() method:
class MyViewSet(ListEnvelopeMixin, ReadOnlyModelViewSet):
envelope = "my_envelope"
In your ViewSet class that uses the mixin you have to define the envelope attribute.
Additionally, you can overwrite the get_envelope() method to tweak the behaviour of
which envelope use in different situations.
Example
By default, django REST ViewSets return a list:
[
{ "id": 1, "foo": "bar" },
{ "id": 2, "foo": "baz" }
]
Once the mixin is applied to that same ViewSet, you get, instead, the following response:
{
"my_envelope": [
{ "id": 1, "foo": "bar" },
{ "id": 2, "foo": "baz" }
]
}
Licence
This package is distributed under MIT Licence.
Metadata
Release files for django-rest-envelope 1.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| django_rest_envelope-1.2.0-py3-none-any.whl | Python 3 | none | any | Details for django_rest_envelope-1.2.0-py3-none-any.whl |
Release files / django_rest_envelope-1.2.0-py3-none-any.whl
| Download URL | django_rest_envelope-1.2.0-py3-none-any.whl |
|---|---|
| Size | 3.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
6708f9ffbfe6052ee4508c69c5b1d026382e4aad93d107670a3122c6210e8d59
|
|
BLAKE2b-256 checksum How to use checksums |
8b850118cc1ea0bd86a287b40a7e11e224444920877f50dbfa7958f21b786547
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.11.17
|
Security for django-rest-envelope 1.2.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.