[Answer]-Django tests failing with create table

1👍

✅

The problem (if my psychic debugging is correct) is that the code that defines the management_map field is executed before the Management table has been created. So the
Management.objects.all() method throws an exception.

This does not pose a problem in your normal database since both tables exist — however I believe that if you deleted the database and tried to do syncdb again you’ll experience the same error.

In any case, a Q+D way to fix it is to make sure that the Management table has been created when the management_map field is declared. Try to put the Management class definition at the top of your source file of they are in a different file then try reordering your imports.

Leave a comment