Skip to main content

Call django model full_clean() when validate ModelSerializer

Project description

drf-fullclean

PyPI - Version PyPI - Downloads

Call django Model.full_clean(exclude=None, validate_unique=True) when invoke serializer.is_valid() of ModelSerializer

Installation

pip install drf-fullclean

Usage

from drf_fullclean.serializers import FullCleanModelSerializer

class MyModelSerializerClass(FullCleanModelSerializer):
  class Meta:
      model = MyModel
      fields = '__all__
s = MyModelSerializerClass(data=request.POST)
s.is_valid(raise_exception=True)
s.save()

When you call s.is_valid(raise_exception=True) this method invoke also Model.full_clean() method.

The validation FAIL IF Model.full_clean() FAIL.

API

is_valid() is extended with Model.full_clean() api.

is_valid(self, raise_exception=False, exclude=None, validate_unique=True, extra_include=None, *args, **kwargs)

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

drf_fullclean-0.0.2.tar.gz (5.2 kB view details)

Uploaded Source

Built Distribution

drf_fullclean-0.0.2-py3-none-any.whl (6.2 kB view details)

Uploaded Python 3

File details

Details for the file drf_fullclean-0.0.2.tar.gz.

File metadata

  • Download URL: drf_fullclean-0.0.2.tar.gz
  • Upload date:
  • Size: 5.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.9.6

File hashes

Hashes for drf_fullclean-0.0.2.tar.gz
Algorithm Hash digest
SHA256 67930c1596fe35b9930f968ae364a1156160fb797d50112ba682917902338c46
MD5 78b23663237a0551f15cb4c792a5e6fb
BLAKE2b-256 7149d19ca629c5973f0688c8810434216265e89b2fca36e5bb4076bb87bf3ea3

See more details on using hashes here.

File details

Details for the file drf_fullclean-0.0.2-py3-none-any.whl.

File metadata

File hashes

Hashes for drf_fullclean-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 038d121cd938b9058c5380aae929cfc8657e3d7b34a2955977d13b3804164916
MD5 4fb7aaba937d99cccfd456a1bd75638e
BLAKE2b-256 878504d05342e553c9a375dc0dbdfe538642ac32655fd407fd73338e90cf0e3d

See more details on using hashes here.

Supported by

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