[Django]-DJANGO CHECK CONSTRAINTS: SystemCheckError: (models.E032) constraint name 'age_gte_18' is not unique amongst models


You’re trying to define two different indexes with the same name, age_gte_18. The system check is telling you not to do that. That limitation doesn’t seem to be discussed in the Django documentation, but presumably is a limitation of one or more of the supported databases (see this answer, for example).

The solution is simple—give each index a unique name (or simply leave the name out).


You can ignore the system check with the Django setting SILENCED_SYSTEM_CHECKS = ["models.E032"]

Here is the reference for the SILENCED_SYSTEM_CHECKS setting.

Only ignore system checks if you know what you are doing. For example I needed to ignore this check when connecting Django to an existing MySQL database with several indexes on different tables using the same name. In the version of MySQL I was using this is not an issue whereas in other database backends it is.

Leave a comment