PROJECTS NOTES HOME

Move models from one app to another

Inspiration - https://stackoverflow.com/questions/25648393/how-to-move-a-model-between-two-django-apps-django-1-7

I had to move the model from one app to another.

Tried various methods, such as:

But after each case I would face some kind of error would occur. I will describe a method that I have used and that has worked for me just fine.

It was very good to practice this in my DEV environment, having copies of sqlite3 DB files and to be able to visually see the content of the DB as I was doing this.

But for those that do not have access to sqlite3 DB file or can not preview their content in the GUI as I could in VScode or in sqlitebrowser, I will write as detailed instructions as I can below. They helped me to execute the same commands in my PROD server afterwards(did not have a gui as well).

note: you can ignore the --settings=settings.development everywhere you see it, you will not need it, it is just a part of my config, because I have split my Django settings.py file into dev and prod. TOOD

If you see a command like such:

python manage.py makemigrations base_app --settings=settings.development

It means that you have to run your command like that(and change the "base_app" to your app name):

python manage.py makemigrations base_app