[Django]-ManyToManyField references the 'id' field when using a custom primary key

2👍

It seems the migration doesn’t detect Foreign Key type changes well. It’s a known bug. A workaround is mentioned here (i.e to explicitly change the field type to varchar(32)).

However, you may need to do more (like updating the constraints etc. on the table) depending on your use case. (For those interested to go that route, here is one example case with corresponding migration code).

(p.s I just decided to not use a custom primary key on models with manytomany fields)

👤Anupam

Leave a comment