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:

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:

  1. Move all models to the new app. (Let's call it "newapp".)
  2. Update all references in the code to the previous locations. (Including migration files.)
  3. Take down the site for a minute.
  4. Run a script to rename all database tables from someprevapp_model to newapp_model.
  5. Run a script to update app_label for all rows in the django_content_type table.
  6. Deploy latest codebase version, with updated model locations and references.
  7. Turn site back on.

Have I succeeded, or am I missing something?

Back to Top