Django 1.9 ./manage.py migrate error

2,533 views
Skip to first unread message

Xuton Ion

unread,
Dec 12, 2015, 8:42:58 AM12/12/15
to Django users
Hi

I seem to have an issue with running migrate and have been googling all day without any luck

I have an app which works and runs on 1.8
After cloning the repo and creating a new ve, I ended up with Django 1.9

Running the ./manage.py migrate creates the database, but none of the tables from the model. It returns
django.db.utils.OperationalError: no such table: table_name

If I delete the db.sqlite3 (still in dev so not postgress yet), deactivate my ve and use my ve with django 1.8, the migrate line runs fine. 
If I then re-activate my ve with 1.9, everything works fine. I can make changes and run makemigrations, and it works. But the initial state seems to not work

Anyone else have the same issue, or have some advice for me?

Tim Graham

unread,
Dec 12, 2015, 9:26:15 AM12/12/15
to Django users
Does your application have migrations? Quoting the 1.9 release notes, "Automatic syncing of apps without migrations is removed. Migrations are compulsory for all apps unless you pass the --run-syncdb option to migrate."

Xuton Ion

unread,
Dec 12, 2015, 11:53:37 AM12/12/15
to Django users
No, I haven't added any migrations. 

I did try with --run-syncdb though, and still had the same error though

Tim Graham

unread,
Dec 12, 2015, 12:14:55 PM12/12/15
to Django users
Is there a reason you can't use migrations? --run-syncdb is really only meant for huge projects (hundreds or thousands of models) where migrations are too slow. Not sure why it's not working though. You'd have to project a sample project for me to debug further.

Xuton Ion

unread,
Dec 13, 2015, 1:01:39 AM12/13/15
to Django users
Thanks for the assistance so far.

Reading https://docs.djangoproject.com/en/1.9/topics/migrations/ it says I should be able to run migrate to apply migrations.
But does this mean I have to manually do something, or should that work the same as it did on 1.8?

I am assuming that it should also be able to create the database from the model with just running that one command.

When creating a new project the migrate line runs fine, so it seems to be something specific to the project. I cant share the project though

Marisa DeMeglio

unread,
Jan 17, 2016, 12:48:22 PM1/17/16
to Django users
Did you ever figure this out? I just upgraded from Django 1.8 to 1.9 and I'm having the same issue.

Marisa DeMeglio

unread,
Jan 17, 2016, 2:08:38 PM1/17/16
to Django users
Ok I had to run these commands to make it work:

$manage.py makemigrations <app_name> 
$migrate --fake-initial.

(for reference: django 1.9.1 / sqlite / OSX / python 3.4)

Xuton Ion

unread,
Mar 6, 2016, 5:50:16 PM3/6/16
to Django users
Hi, thanks for the reply.
So, did you have a db in the project? I cloned the project again and tried to create the db from the model, but using your suggestion doesn't work.
I can only get 1.9 working if I already have a db from 1.8, but not creating a new one from scratch.

Neither the first or second line runs, they both exit with the same error. Table doesn't exist

Tejesh Papineni

unread,
Jun 3, 2016, 12:26:04 PM6/3/16
to Django users
its working when already have a db because views.py are using Models from already existing db. But when creating new db, code in views.py is trying to access Models that have not yet been built using ./manage.py migrate. My solution is to comment code in views.py that accesses Models or try except with OperationalError , then run migrations (which will work now). Afterwards revert to old views.py code.

Owen Chung

unread,
Jan 31, 2017, 11:34:37 PM1/31/17
to Django users
That works for me. You save my life. Thank you!
Reply all
Reply to author
Forward
0 new messages