1👍
The problem is that the code is running loaddata
before the database table has been set up, hence it can’t write the Site
value.
Normally manage.py test
takes care of setting up the test databases – are you running using a different / custom test runner? If not, then try stepping through manage.py test
to see what the initialisation order of your test code versus the calls to syncdb
are.
If you’re using your own test runner, then add appropriate calls to syncdb
. Make sure you pick up the South version if using South, and/or set SOUTH_TESTS_MIGRATE = False
Source:stackexchange.com