Link a couple of articles on constraint examples

This commit is contained in:
Radoslav Georgiev 2021-09-16 17:35:57 +03:00
parent 40615d099b
commit 969a1642ce
No known key found for this signature in database
GPG Key ID: 0B7753A4DFCE646D

View File

@ -178,6 +178,12 @@ Less code to write, less to code to maintain, the database will take care of the
**TODO:** Add above example with constraints. **TODO:** Add above example with constraints.
The Django's documentation on constraints is quite lean, so you can check the following articles by Adam Johnson, for examples of how to use them:
1. [Using Django Check Constraints to Ensure Only One Field Is Set](https://adamj.eu/tech/2020/03/25/django-check-constraints-one-field-set/)
1. [Djangos Field Choices Dont Constrain Your Data](https://adamj.eu/tech/2020/01/22/djangos-field-choices-dont-constrain-your-data/)
1. [Using Django Check Constraints to Prevent Self-Following](https://adamj.eu/tech/2021/02/26/django-check-constraints-prevent-self-following/)
### Properties ### Properties
Model properties are great way to quickly access a derived value from a model's instance. Model properties are great way to quickly access a derived value from a model's instance.