Django - Datamigration for an external application

Is there a way to properly create data migration for third-party Django applications?

The launch python manage.py makemigrations --empty <externa-app-label>works, but creates migrations in the application directory (which is inside the virtual environment ... does not want to mess with this).


Here is my case:

I need to replace one of the internal applications of the Django project with an external application with similar functionality, and then delete the old internal application. These applications have models, and there is an existing database for the project that will need to be migrated. I would associate the data transfer with the old application if I did not delete it later.

A simple example of the need for something like this might just be the need to populate a third-party application with some raw data.

+4
source share
1 answer

Just create data migration as part of one of your internal applications and just do data manipulation (maybe even create a temporary application just for this purpose?)

An important bit is adding a new dependency to the data transfer file. Something like this, but of course, find the last migration name in the directory extenralapp/migrations(or some other directory if it is overridden in settings.MIGRATION_MODULES).

class Migration(migrations.Migration):

    dependencies = [
        ('yourapp', '0004_auto_20151216_1509'),
        ('externalapp', '0011_20010203_1415'),  # this line
    ]

    ...

A related thing ...

If you use models ContentTypeand / or auth.Permission, you may have problems retrieving them. Both of these models are created at the end of a successful team manage.py migrate.

, , , (.. db). . # 23422 .

+1

All Articles