Ticket #1128 (closed defect: invalid)

Opened 3 years ago

Last modified 3 years ago

Allow for models that have app_label set to a 3rd party library's app name

Reported by: berryphillips@… Owned by: andrew
Priority: major Milestone:
Component: migrations Version: 0.7.5
Keywords: Cc:


If you have a model with the app_label set to a 3rd party library's app name south will not add migrations for that model. For example:

If you have an app in your project called user_profiles with the following models.py:

from django.db import models
from django.contrib.auth.models import User

class UserProfile(models.Model):
    user = models.OneToOneField(User)
    job_title = models.CharField(max_length=100)

    class Meta:
        app_label = 'auth'

When running the initial schemamigration, the migrations folder is created and an initial migration script is added. However, the script is empty. If you comment out the app_label and run the initial schemamigration the migration is created successfully. If you uncomment the app_label and try adding a new field and run an auto schemamigration a migration gets added to remove the model.

If you leave app_label commented out whenever creating migrations but uncomment it when actually executing the migrations the table is created as expected. In this case that would be auth_userprofile.

South should automatically take this into account when generating migrations. I should be able to define the app_label as anything I like and have south generate migrations as expected.


Python 2.7.2
Django 1.4
South 0.7.5

Change History

comment:1 Changed 3 years ago by andrew

  • Status changed from new to closed
  • Resolution set to invalid

South is behaving exactly as it should - creating migrations on a per-app basis. As soon as you define the app_label to be another app, Django moves the model over to that app's set of models internally and so when South asks for the main app's model set Django returns nothing.

I'm not sure why you want to change the app_label like this, but the only way you'll be able to migrate that model this way is by adding on migrations to the third-party app (and that's bound to cause trouble). You'd be a lot better off keeping models and apps together.

Note: See TracTickets for help on using tickets.