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
Close
Hashes for django-rest-inherits-error-messages-1.0.0.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8438871f99c08e990fec34d6319ce2dc414bd84c6efc103c46093eb0e4b36750 |
|
MD5 | 36878db0620bfec6c2365aa67fb56ca0 |
|
BLAKE2b-256 | abbccf77d866424b5181c5192cb7669072e44eba4aad78e07e1b0c9c871b8062 |
Close
Hashes for django_rest_inherits_error_messages-1.0.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 93d52f5c6160af54839f7e125f6ed248fa9b3d783afd92f6dbfba6f9c24283b8 |
|
MD5 | d77c2eccb454127c6ecf6d97f254b94e |
|
BLAKE2b-256 | f78c8820ef9a753a0159d0ab507eb8d4d2761dec364882a14756cb8615d9d62a |