Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error: One or more models did not validate: #1

Open
christaggart opened this issue Apr 14, 2012 · 8 comments
Open

Error: One or more models did not validate: #1

christaggart opened this issue Apr 14, 2012 · 8 comments

Comments

@christaggart
Copy link

Fresh django-shop install and getting this issue (which I noticed you were trying to sort out on SO).

python manage.py migrate area_tax

Error: One or more models did not validate:
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'.
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'.

@Lacrymology
Copy link
Owner

As far as I understand this, it is a problem with the way the Address
model is designed in django-shop. Tests will fail as well, if you have
an address model defined in your apps, whether you are using it or
not, because django-shop's tests will import their own address model,
and then you'll get this exact same issue: two related_names of
"billing_address" and "shipping_address" for the User model.

If you're going to use the area_tax's model address, then removing
shop.addressmodel from your INSTALLED_APPS should do the trick here,
if not, I'll try to think of a way of fixing this, probably something
like testing the address model setting and not defining the model if
it's something else.

@christaggart
Copy link
Author

Hmm, I removed shop.addressmodel form INSTALLED_APPS, but still running into the same error.

@Lacrymology
Copy link
Owner

At the very least, you shouldn't be getting the 'addressmodel.address'
part of it. Can you grep for imports of shop.addressmodel.models or
similar in your code or other django-shop plugins?

@Lacrymology
Copy link
Owner

Or maybe you could describe a minimal way of reproducing this error? like, create a new virtualenv, install django, and django-shop, have this and this apps installed in, and syncdb.. bam!

@Lacrymology
Copy link
Owner

I just thought of something, but since I cannot reproduce your bug, I don't know if it'd work. Can you try setting up l10n.models.Address.Meta.abstract = True and then creating your own Address model inheriting from it and using that instead?

@christaggart
Copy link
Author

There literally is no other addressmodel defined. As a starting point, I removed l10n from installed apps, and get this:

INSTALLED_APPS = (
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.messages',
'django.contrib.staticfiles',
'django.contrib.admin',
'debug_toolbar',
'south',
'shop',
'area_tax',
#'shop.addressmodel',
'store',
#'paypal.standard.ipn',
#'paypal.pro',
#'shop_paypal',
#'gargoyle',
'easy_thumbnails',
#'shop_onepage',
)

area_tax.areatax: 'country' has a relation with model <class 'l10n.models.Country'>, which has either not been installed or is abstract.
area_tax.areatax: 'area' has a relation with model <class 'l10n.models.AdminArea'>, which has either not been installed or is abstract.

Okay, great, let's add l10n back in...

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'.

INSTALLED_APPS = (
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.messages',
'django.contrib.staticfiles',
'django.contrib.admin',
'debug_toolbar',
'south',
'shop',
'l10n',
'area_tax',
#'shop.addressmodel',
'store',
#'paypal.standard.ipn',
#'paypal.pro',
#'shop_paypal',
#'gargoyle',
'easy_thumbnails',
#'django_countries',
)

@Lacrymology
Copy link
Owner

so... what? what happened when you added l10n back? I see no errors there.

I've noticed a couple of things that are a problem, first of all, that putting the Address model in models.py will bring trouble if you want to define your own address model.

The Address model was always defined in l10n, not in area_tax. Now I've made it abstract, so it won't clash with other models if there are any. This means you need to add to some models.py of your own a

from l10n.models import Address as _Address
class Address(_Address):
    pass

and then in your settings.py make SHOP_ADDRESS_MODEL = '<yourapp>.Address'. There'll probably a number of syncdbs and/or migrations involved. Sorry, it's a WIP =), but I've got that setup going on, and it seems to work fine.

@christaggart
Copy link
Author

That seems to have worked. Still can't run migrations or spin up dev server though.

Error: One or more models did not validate:
store.address: Accessor for field 'address_ptr' clashes with field 'Address.address'. Add a related_name argument to the definition for 'address_ptr'.
store.address: Reverse query name for field 'address_ptr' clashes with field 'Address.address'. Add a related_name argument to the definition for 'address_ptr'.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants