Skip to main content

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

django-rest-inherits-error-messages-1.0.0.tar.gz (2.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

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

Hashes for django-rest-inherits-error-messages-1.0.0.tar.gz
Algorithm Hash digest
SHA256 8438871f99c08e990fec34d6319ce2dc414bd84c6efc103c46093eb0e4b36750
MD5 36878db0620bfec6c2365aa67fb56ca0
BLAKE2b-256 abbccf77d866424b5181c5192cb7669072e44eba4aad78e07e1b0c9c871b8062

See more details on using hashes here.

File details

Details for the file django_rest_inherits_error_messages-1.0.0-py3-none-any.whl.

File metadata

File hashes

Hashes for django_rest_inherits_error_messages-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 93d52f5c6160af54839f7e125f6ed248fa9b3d783afd92f6dbfba6f9c24283b8
MD5 d77c2eccb454127c6ecf6d97f254b94e
BLAKE2b-256 f78c8820ef9a753a0159d0ab507eb8d4d2761dec364882a14756cb8615d9d62a

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page