[Django]-Django 1.7 makemigrations not working – has no column named

2👍

Line 54 in categories/models.py:

tweetidnum=user_timeline[x]['id_str'])

That is apparently somehow trying to create a Category instance and save it when the module is imported. This prevents the migration from running at all, as an uncaught exception is raised before the migrations get a chance to run.

You’ll have to provide more code if you want the exact cause, but that line is the culprit. I suspect it is part of a multi-line create statement.

👤knbk

2👍

Your migrations weren’t applied correctly.

Do a python manage.py migrate -l categories. It should list the applied migrations in that app. Have a look at the last one (or the one you think user_photo had to be added) and watch the file.

Once you identify which is the migration that has to add the field, do a python manage.py migrate polls $prev where $prev is the previous migration in the list and python manage.py migrate polls $migration where $migration is the one adding the field.

If this does not work, I would say that the fastest approach without losing data is creating the column yourself with ALTER TABLE categories ADD COLUMN "userphoto" varchar(100) NOT NULL;

👤argaen

Leave a comment