Reputation: 2259
It fails with a number of related_name-related issues. Of course when running the actual dev server (with ./manage.py runserver
) this doesn't happen, I'm guessing maybe the models are being generated twice? I'm running psycopg2 2.4.1, and here's my test output:
(venv)lacrymology@Roller:boilerplate$ ./manage.py test
Creating test database for alias 'default'...
Error: One or more models did not validate:
l10n.address: Accessor for field 'user_shipping' clashes with related field 'User.shipping_address'. Add a related_name argument to the definition for 'user_shipping'.
l10n.address: Reverse query name for field 'user_shipping' clashes with related field 'User.shipping_address'. Add a related_name argument to the definition for 'user_shipping'.
l10n.address: Accessor for field 'user_billing' clashes with related field 'User.billing_address'. Add a related_name argument to the definition for 'user_billing'.
l10n.address: Reverse query name for field 'user_billing' clashes with related field 'User.billing_address'. Add a related_name argument to the definition for 'user_billing'.
custom_registration.profile: Accessor for field 'user' clashes with related field 'User.profile'. Add a related_name argument to the definition for 'user'.
custom_registration.profile: Reverse query name for field 'user' clashes with related field 'User.profile'. Add a related_name argument to the definition for 'user'.
addressmodel.address: Accessor for field 'user_shipping' clashes with related field 'User.shipping_address'. Add a related_name argument to the definition for 'user_shipping'.
addressmodel.address: Reverse query name for field 'user_shipping' clashes with related field 'User.shipping_address'. Add a related_name argument to the definition for 'user_shipping'.
addressmodel.address: Accessor for field 'user_billing' clashes with related field 'User.billing_address'. Add a related_name argument to the definition for 'user_billing'.
addressmodel.address: Reverse query name for field 'user_billing' clashes with related field 'User.billing_address'. Add a related_name argument to the definition for 'user_billing'.
profiles.profile: Accessor for field 'user' clashes with related field 'User.profile'. Add a related_name argument to the definition for 'user'.
profiles.profile: Reverse query name for field 'user' clashes with related field 'User.profile'. Add a related_name argument to the definition for 'user'.
Upvotes: 1
Views: 1755
Reputation: 23871
It is highly possible that your test.py imports an app which is not inside INSTALLED_APP but has some model fields pointing to the collided model. Try to grep user_shipping inside apps which are imported in test.py but not inside INSTALLED_APPS, and replace it.
./manage.py validate
, which will be called internally by ./manage.py runserver
, only checks models loaded from apps inside INSTALLED_APP and thus there was no error when you ran devserver. However, imports inside test.py will cause extra models of non-installed apps, if there is any, to be loaded and then collision will happen.
Upvotes: 1
Reputation: 2259
This was an issue with django-shop tests, as described in this comment: Django test fails when creating test database
I could find no way around it without changing the app's code, so I ended up just testing my own apps (running ./manage.py test myapp
instead of ./manage.py test
Upvotes: 0