This is by design. Reading the documentation for the unique_together option, she states that:
It is used by the Django admin, and applied at the database level .
If you look at the table that the subclass creates, you will see that in fact it does not have the fields that its parent has. Instead, it gets a soft foreign key to the parent table with the name of the field called [field]_ptr_id , where [field] is the name of the table that you inherit, with the exception of the application name. So your partition table has a primary foreign key called organization_ptr_id .
Now, since unique_together is applied at the database level using the UNIQUE , I donβt know how to do this so that the database really applies this to a field not contained in the table.
Itβs best to use Validators at your business logic level or revise your database schema to support constraints.
Edit: as Manoah pointed out, you can also try using Model Validators , such as validate_unique .
Pewpewarrows
source share