[Answered ]-Django migration is creating extra table

1👍

Nothing is wrong. In database terms a ManyToManyField is just an extra intermediate table which has foreign keys to the two related tables. This is because you really cannot have multiple values in the same column pointing to multiple entries.

Your first table matchsystem_matchlist you show in the image has the fields id and user_id which is correct, id is the primary key and user_id is the foreign key (in your model user). This is the table for your model MatchList.

Next your second table matchsystem_matchlist_matches has the fields id which is the primary key, matchlist_id which is the foreign key to MatchList and users_id which is the foreign key to the user model. This second table is the intermediate table made for the ManyToManyField named matches in your model MatchList.

Leave a comment