[Answer]-South datamigrate add Sites as defaults

1👍

Here is the Source of Site

Since there is no app_name specified the default is taken. Hence the app_name
Here is site

0👍

This is a data migration from one of my projects which adds the current site (i. e. settings.SITE_ID) to each Gallery object:

class Migration(DataMigration):

    def forwards(self, orm):
        current_site = orm['sites.Site'].objects.get(pk=settings.SITE_ID)

        for gallery in orm.Gallery.objects.all():
            gallery.sites.add(current_site)

    def backwards(self, orm):
        raise RuntimeError("Cannot reverse this migration.")

Also see South’s own documentation on data migrations.

👤jnns

Leave a comment