Skip to content

Commit

Permalink
Add a note about Django constraints for custom validation
Browse files Browse the repository at this point in the history
  • Loading branch information
RadoRado committed Oct 27, 2019
1 parent c986c1e commit 3c40f63
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 3c40f63

Please sign in to comment.