python - How to disable migrations for specific Django 1.7 apps? -
how disable migrations specific apps in django>=1.7?
i'm trying upgrade django 1.6 1.7, , made trivial changes django's auth app change labels, design flaw in django>=1.7 treats attributes part of database schema, triggering new migration. moreover, running manage.py makemigration myapp
generates migration other apps touching myapp
, though i'm not explicitly trying create migration auth
, it's forcing me so, , see no way turn off.
this creating havoc, since have dozen apps touch auth
, causing django create on dozen pointless migrations.
i tried creating custom auth
migration directory using migration_modules
, doesn't seem work. app relies on auth throws error like:
valueerror: lookup failed model referenced field helpdesk.queue.group: auth.group
if try migrate auth
. how fix this? ideally, simplest solution "turn off" migrations auth
, since i'm not making changes it.
edit: custom migration django forces me generate:
class migration(migrations.migration): dependencies = [ ('admin', '0001_initial'), ('auth', '0001_initial'), ] operations = [ migrations.createmodel( name='logentry', fields=[ ], options={ 'ordering': ('-action_time',), 'verbose_name': 'log entry', 'proxy': true, 'verbose_name_plural': 'log entries', }, bases=('admin.logentry',), ), migrations.alterfield( model_name='permission', name='name', field=models.charfield(max_length=500, verbose_name='name'), preserve_default=true, ), migrations.alterfield( model_name='user', name='username', field=models.charfield(help_text='required. 30 characters or fewer. letters, digits , @/./+/-/_ only.', unique=true, max_length=75, verbose_name='username', validators=[django.core.validators.regexvalidator('^[\\w.@+-]+$', 'enter valid username.', 'invalid')]), preserve_default=true, ), ]
my custom changes make username , email fields same length (because 2 same in system), change default validator validate them both email address. i've been using these changes since django 1.3. presumably, they're problem i'm no longer using south , have re-generate migrations.
and looks can't use migration_modules
generate custom migration folder, because have other apps depend on auth's 0001_initial migration, like:
class migration(migrations.migration): dependencies = [ migrations.swappable_dependency(settings.auth_user_model), ]
so if override migration_modules
like:
migration_modules = { 'auth': 'myoverrides.auth_migrations', }
that migration disappears, throwing error.
it's bit of hack, modified settings.py
check sys.argv
"makemigrations" , remove conflicting apps, unmanaged, installed_apps
list. allowed me generate custom auth
migration. e.g.
if 'makemigrations' in sys.argv installed_apps.remove('conflicting_third_party_app')
Comments
Post a Comment