Django - How to make migrations locally within an application while overriding User or Group model? -


i have application 'registration' in trying add field in django auth groups. have implemented using monkey patching. however, when post application else , run 'migrate', build fails stating reason newly added field not exists. reason being when created migrations, migration files not created in 'registration' application, instead, created in django.contrib.auth application.

how can past problem?

i solved adding dummy migration file in application - 'registration'. inside migration, created column manually executing sql query build not fail. i'll post code here.

def check_and_add_column(apps, schema_editor):   import sqlite3   conn = sqlite3.connect('db7.sqlite3')   cur = conn.cursor()   result = [true in cur.execute('pragma table_info(auth_group)') if i[1] == 'is_auto_assign']    if not result:       cur.execute('alter table auth_group add column is_auto_assign boolean default false')  class migration(migrations.migration):   dependencies = [     ('auth', '0001_initial'),   ]    operations = [       migrations.runpython(check_and_add_column,),        # if need run sql directly here       # migrations.runsql("alter table auth_group add column is_auto_assign boolean default false"),   ] 

Comments

Popular posts from this blog

PHP DOM loadHTML() method unusual warning -

python - How to create jsonb index using GIN on SQLAlchemy? -

c# - TransactionScope not rolling back although no complete() is called -