From 3c40f63acac223b5c91089281ab94f4309ecefb5 Mon Sep 17 00:00:00 2001 From: Radoslav Georgiev Date: Sun, 27 Oct 2019 17:23:28 +0200 Subject: [PATCH] Add a note about Django constraints for custom validation --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index db9f4de..72ef7ca 100644 --- a/README.md +++ b/README.md @@ -167,6 +167,7 @@ We have few general rules for custom validations & model properties / methods: * If the custom validation depends only on the **non-relational model fields**, define it in `clean` and call `full_clean` in `save`. * If the custom validation is more complex & **spans relationships**, do it in the service that creates the model. * It's OK to combine both `clean` and additional validation in the `service`. +* As proposed in [this issue](https://github.com/HackSoftware/Django-Styleguide/issues/22), if you can do a validation using [Django's constraints](https://docs.djangoproject.com/en/2.2/ref/models/constraints/), then you should aim for that. Less code to write. ### Properties