Django REST framework keywords names for extra_keyword meta attribute of serializers stored as constants
Project description
drfkwargs
Django REST framework keywords names for extra_keyword meta attribute of serializers stored as constants
Installing
[!NOTE] It's recommended to activate Virtual Environment before installing drfkwargs
To clone and install required packages use the following command:
# linux/macOS
$ python3 -m pip install drfkwargs
# windows
$ py -3 -m pip install drfkwargs
Quick example
import django.contrib.auth.models
import rest_framework.serializers
import drfkwargs
class UserSerializer(rest_framework.serializers.ModelSerializer):
class Meta:
model = django.contrib.auth.models.User
fields = rest_framework.serializers.ALL_FIELDS
extra_kwargs = {
model.password.field.name: {drfkwargs.WRITE_ONLY: True},
model.user_permissions.field.name: {drfkwargs.WRITE_ONLY: True},
model.groups.field.name: {drfkwargs.WRITE_ONLY: True},
}
Class-based kwargs
For more readability you can use class-based keyword argument sets,
which are classes providing the set of the kwargs names available for a serializer.
Going with this, it's possible to replace drfkwargs.INPUT_FORMATS with drfkwargs.DateFieldKwargs.INPUT_FORMATS.
These two are the equivalents, but the second one provides more information about what is this kwarg
[!NOTE] Every serializer provided by
DRFhas its own class-based kwarg set
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
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 drfkwargs-1.0.0.tar.gz.
File metadata
- Download URL: drfkwargs-1.0.0.tar.gz
- Upload date:
- Size: 4.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8fb420b82be5511dac4ae44ad124a892393a695244a44b256911e09d658ed0ad
|
|
| MD5 |
0177177a8adc5f02a1a3693e29862a4d
|
|
| BLAKE2b-256 |
460c0e56c9e7fce67a1909dd6df709ab05ef33fcc10c972649b7fd6421275825
|
File details
Details for the file drfkwargs-1.0.0-py3-none-any.whl.
File metadata
- Download URL: drfkwargs-1.0.0-py3-none-any.whl
- Upload date:
- Size: 5.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d493049ca8179dd4dfd32e6d4c29cfc3ac8e32a18a3dfa5700e2686c5444a0f7
|
|
| MD5 |
f6b8fb3a51b62d4ba52d8e0089ce953b
|
|
| BLAKE2b-256 |
acd8bf89843fbb9f2dc248228c2a2e584dd0f9e4f709fb5076dbeece24a88f8f
|