Answer the question
In order to leave comments, you need to log in
How to rename an application in Django?
Good afternoon!
With the growth of my project, it became necessary to split it into several applications.
If I create a new application, transfer the necessary models to it and make a migration, then the old database will be deleted and a new one will be created. Without calculating this, I lost some of the data on the server when I deployed. Can you please tell me how to do this without losing data, but at the same time rename the table from [old_app]_table to [new_app]_table?
Answer the question
In order to leave comments, you need to log in
In recent versions of Django, you can separate the actual operations from those that Django invents for you. Renaming tables is even easier: set the table name in the model, rename the model, change the table name. Django successfully detects this as a rename .
Moving between applications will be more difficult, because you need to explain to Django that nothing needs to be done in the database.
But there is a nuance here: if something goes wrong in the process of rolling a migration with renaming tables, then part of the site will be unavailable. Actually, you will get 500x in any case, if someone sits on the site during the rollout of the release.
I'm sorry for the late reply. I just noticed the notification. I solved the problem head-on - I split the project into applications and manually renamed the tables using the sqlite3 console utility.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question