fpghost
fpghost

Reputation: 2944

Get unique together constraint name in db in Django

How can I get the name of a unique together constraint in Django?

It seems to be generated quite randomly to e.g. book_membership_collection_id_order_c52e778f_uniq, and I need to programatically get this name to do something with RunSQL

Upvotes: 1

Views: 111

Answers (1)

fpghost
fpghost

Reputation: 2944

I found it was possible via

connection.schema_editor()._constraint_names(MYModel, ['col1', 'col2'], unique=True)

Upvotes: 1

Related Questions