ModelSerializer inherits the error_messages of the model
Project description
Django Rest Error Inherits Error Messages
ModelSerializer inherits the error_messages of the model
Example
pip install django-rest-inherits-error-messages
Set error_messages in your model field. models.py
class TestModel(django.db.models.Model):
id = models.BigAutoField(primary_key=True)
name = models.CharField(max_length=10, error_messages={'required':'[test] This field is required.'})
Go to your ModelSerializer and inherit the InheritsModelSerializer (InheritsHyperlinkedModelSerializer also exists)
class TestSerializer(InheritsModelSerializer):
class Meta:
model = TestModel
fields = '__all__'
If set as above, error_messages will be inherited.
Contributions
Issues and PR are welcome.
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 django-rest-inherits-error-messages-1.0.0.tar.gz.
File metadata
- Download URL: django-rest-inherits-error-messages-1.0.0.tar.gz
- Upload date:
- Size: 2.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.3.0 pkginfo/1.6.1 requests/2.25.1 setuptools/51.1.1 requests-toolbelt/0.9.1 tqdm/4.55.1 CPython/3.8.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8438871f99c08e990fec34d6319ce2dc414bd84c6efc103c46093eb0e4b36750
|
|
| MD5 |
36878db0620bfec6c2365aa67fb56ca0
|
|
| BLAKE2b-256 |
abbccf77d866424b5181c5192cb7669072e44eba4aad78e07e1b0c9c871b8062
|
File details
Details for the file django_rest_inherits_error_messages-1.0.0-py3-none-any.whl.
File metadata
- Download URL: django_rest_inherits_error_messages-1.0.0-py3-none-any.whl
- Upload date:
- Size: 2.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.3.0 pkginfo/1.6.1 requests/2.25.1 setuptools/51.1.1 requests-toolbelt/0.9.1 tqdm/4.55.1 CPython/3.8.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
93d52f5c6160af54839f7e125f6ed248fa9b3d783afd92f6dbfba6f9c24283b8
|
|
| MD5 |
d77c2eccb454127c6ecf6d97f254b94e
|
|
| BLAKE2b-256 |
f78c8820ef9a753a0159d0ab507eb8d4d2761dec364882a14756cb8615d9d62a
|