In model constraints, you can only refer to fields of the model itself. If you want to reference fields of a ForeignKey model, you can override the clean() method. You can see an example here : https://stackoverflow.com/a/75640733/20712534