python - django migration table does not exist -
i have added new model app. did makemigration , in migration can see code create models like:
operations = [ migrations.createmodel( name='blog', fields=[ ('id', models.autofield(verbose_name='id', serialize=false, auto_created=true, primary_key=true)), ('title', models.charfield(max_length=120)), ('body', models.textfield()), ('post_date', models.datetimefield(default=django.utils.timezone.now)), ('like', models.integerfield(default=0)), ('created_by', models.foreignkey(to=settings.auth_user_model)), ], options={ }, bases=(models.model,),
now when python manage.py migrate
gives me error saying table not exist..
why getting error. should have been migrated right ? how fix issue?
- drop tables,
- comment-out model in model.py,
- if using django version >= 1.7:
python manage.py makemigrations
python manage.py migrate --fake
else
python manage.py schemamigration someapp --auto
python manage.py migrate someapp --fake
- comment-in model in models.py
- go step 3. but time without --fake
reference: https://stackoverflow.com/a/27583836/4359237
Comments
Post a Comment