views:

867

answers:

2

I am trying to use different open source apps in my project. Problem is that there is a same Model name used by two different apps with their own model definition.

I tried using:

    class Meta:
        db_table = "db_name"

but it didn't work. I am still getting field name clash error at syncdb. Any suggestions.

Update

I am actually trying to integrate Satchmo with Pinax. And the error is:

Error: One or more models did not validate:

contact.contact: Accessor for field 'user' clashes with related m2m field 'User.contact_set'. Add a related_name argument to the definition for 'user'.

friends.contact: Accessor for m2m field 'users' clashes with related field User.contact_set'. Add a related_name argument to the definition for 'users'.

You are right, table names are already unique. I analyzed the model and the Model 'Contact' is in two models of two different apps. When I comment out one of these models, it works fine.

May be the error is there because both apps are in PYTHON_PATH and when other app defines the its model with same name the clash occurs.

A: 

I am actually trying to integrate Satchmo with Pinax. And the error is:

Error: One or more models did not validate:

contact.contact: Accessor for field 'user' clashes with related m2m field 'User.contact_set'. Add a related_name argument to the definition for 'user'.

friends.contact: Accessor for m2m field 'users' clashes with related field User.contact_set'. Add a related_name argument to the definition for 'users'.

You are right, table names are already unique. I analyzed the model and the Model 'Contact' is in two models of two different apps. When I comment out one of these models, it works fine.

May be the error is there because both apps are in PYTHON_PATH and when other app defines the its model with same name the clash occurs.

Irfan
Please edit your question with additional info, do not post a non-answer. Normally I would give this a downvote for that, but I'll hold off since you're new ;-)
Carl Meyer
It doesn't help that you can't comment on people's answers until you've gotten some (50?) points... Editing the answer doesn't come as a natural solution to most people, and in fact, is bad ettiquette in most forums.
Xiong Chiamiov
I merged it to the question. @Irfan: please delete this "answer".
Török Gábor
+3  A: 

The problem is that both Satchmo and Pinax have a Contact model with a ForeignKey to User. Django tries to add a "contact_set" reverse relationship attribute to User for each of those ForeignKeys, so there is a clash.

The solution is to add something like related_name="pinax_contact_set" as an argument to the ForeignKey in Pinax's Contact model, or similarly in the Satchmo Contact model. That will require editing the source directly for one or the other. You might be able to find a way to do it via monkeypatching, but I'd expect that to be tricky.

Carl Meyer