Django: Collision Model Name

I am trying to use various open source applications in my project. The problem is that there is the same model name used by two different applications with their own model definition.

I tried using:

class Meta: db_table = "db_name" 

but it didn’t work. I am still getting a field name collision error on syncdb. Any suggestions.

Update

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

Error: one or more models did not confirm:

contact.contact: Accessor for field "user" collisions with the corresponding m2m field "User.contact_set". Add the related_name argument to the user definition.

friends.contact: Accessory for m2m user conflicts with the corresponding User.contact_set fields. Add the related_name argument to the definition for "users".

You are right, table names are already unique. I analyzed the model, and the Contact model in two models of two different applications. When I comment on one of these models, it works fine.

Maybe the error is that both applications are in PYTHON_PATH, and when another application determines its model with the same name, a collision occurs.

+3
source share
1 answer

The problem is that Satchmo and Pinax have a Contact model with a ForeignKey for the user. Django is trying to add the feedback attribute "contact_set" for the user for each of these ForeignKeys, so there is a collision.

The solution is to add something like related_name = "pinax_contact_set" as an argument to the ForeignKey model in Pinax Contact or similarly in the Satchmo Contact model. This will require editing the source directly for one or the other. You could find a way to do this with monkeypatching, but I would expect it to be difficult.

+6
source

Source: https://habr.com/ru/post/1306230/


All Articles