Manage fields by request params
Project description
Manage fields
Usage
views.py
from manage_fields.mixins import MFViewMixin
class MyView(MFViewMixin, ...):
serializer_class = MySerializer
....
serializers.py
from manage_fields.mixins import MFSerializerMixin
class MySerializer(MFSerializerMixin, ...):
...
Request
https://abcd.com/?allow_fields={id,name}
Params
allow_fields - Fields returned in response
disallow_fields - Fields that are not returned in the response
Example
models.py
class Example(models.Model):
field1 = models.CharField(max_length=50)
field2 = models.TextField()
field3 = models.IntegerField()
Request
https://example.com/?allow_fields={id,field1}
Response
[
{
"id": 1,
"field1": "Field1 value 1"
},
{
"id": 2,
"field1": "Field1 value 2"
}
]
Request
https://example.com/?disallow_fields={id,field1}
Response
[
{
"field2": "Field2 value 1",
"field3": "Field3 value 1"
},
{
"field2": "Field2 value 2",
"field3": "Field3 value 2"
}
]
Also you can use this package for CreateAPIView, UpdateAPIView, RetrieveAPIView
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
manage-fields-0.0.7.tar.gz
(2.3 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file manage-fields-0.0.7.tar.gz.
File metadata
- Download URL: manage-fields-0.0.7.tar.gz
- Upload date:
- Size: 2.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3f911a46550683d992d5e98d33c6f65936548a0b17ed22ace851e0e3d5e6a567
|
|
| MD5 |
84528c07fdc3272f7fc5c96de4b32057
|
|
| BLAKE2b-256 |
34bc52320076591c4aa779cd20a4a63ed2b43981ebaa646a03f868879dc1f445
|
File details
Details for the file manage_fields-0.0.7-py3-none-any.whl.
File metadata
- Download URL: manage_fields-0.0.7-py3-none-any.whl
- Upload date:
- Size: 2.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8a547ec1c0de216b38c4268528c66aac8054c918eea7e34715a88a9a057b4853
|
|
| MD5 |
2fa469dd2dea4f8a61b956ebd602c297
|
|
| BLAKE2b-256 |
6f1e683f8f07d40bd43a226905d44a62cad8434b4945276602a8d3570576982e
|