I\'m running Django 1.11 with Python 3.4 on Ubuntu 14.04.5
Moving my development code to the test server and running into some strange errors. Can anyone see what is wr
In my case, I have the same issue on the development. This command works for me.
python manage.py flush
Make sure it removes all data from the database. Run this command, it will delete all data from the database and run migration again.
python manage.py migrate
The issue is likely related to this open bug in Django. You have some test data in one of the fields that you are now converting to a ForeignKey.
For instance, maybe department
used to be a CharField
and you added an employee who has "test" as their department
value. Now you're trying to change department
from a CharField to a ForeignKey. The issue is that Django is trying to convert the previous value "test" into a relational value (integer) for the ForeignKey.
I can think of a few good solutions:
```
from __future__ import unicode_literals
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('documents', '0042_auto_19700101-0000'),
]
operations = [
migrations.RunSQL('ALTER TABLE documents_document_tags ALTER tag_id TYPE varchar(32);'),
]