monkeyBug
monkeyBug

Reputation: 555

Import app foreign key model class in another app model

I know there are other similar questions, but I have a specific case:

Right now there are two apps: -prev_app -new_app

prev_app contains a "product" model. new_app contains "store" and "contract" model. "store" model has a manytomanyfield to "product" model "contract" is a intermediary model for "store" and "product"

.. .

So now what I want to do is to put that "product" model into the new_app, (so all related models are in one app) but I just don't know how to proceed with the migrations.

Any thoughts?

Upvotes: 0

Views: 283

Answers (1)

doniyor
doniyor

Reputation: 37934

put db_table to your model and move it wherever you want. it refers then always to that old db table and you dont need any migrations for your new app.

class Product(models.Model):
   class Meta: 
     db_table = 'oldapp_tablename'

just be careful that imports should be adjusted according to new layout.

Upvotes: 1

Related Questions