Moving Django models between "apps" - easy and fast
In my company's Django project, our models are currently spread across about 20 "app" folders with little rhyme or reason. We'd like to consolidate them into a single new app (along with the rest of our code) so that in the future, we can refactor all parts of our system at-will without worrying about violating an "app" boundary.
Due to how Django works, simply moving the model breaks everything. I've spent hours reading everything I can about the various proposed solutions to this problem, with the best article being:
https://realpython.com/move-django-model/
So far, I'm not happy with any of the solutions I've come across. They're all just too onerous.
If I do the following:
- Move all models to the new app. (Let's call it "newapp".)
- Update all references in the code to the previous locations. (Including migration files.)
- Take down the site for a minute.
- Run a script to rename all database tables from
someprevapp_model
tonewapp_model
. - Run a script to update
app_label
for all rows in thedjango_content_type
table. - Deploy latest codebase version, with updated model locations and references.
- Turn site back on.
Have I succeeded, or am I missing something?