Created
December 11, 2014 15:44
-
-
Save spookylukey/36acb563acd54fc3ddf0 to your computer and use it in GitHub Desktop.
Bug with Django migrations - migrations created with Python 2 need 'fixing' when run with Python 3
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ mkdir bugtest | |
$ cd bugtest | |
$ virtualenv --python=python2.7 env_p27 | |
Running virtualenv with interpreter /usr/bin/python2.7 | |
New python executable in env_p27/bin/python2.7 | |
Also creating executable in env_p27/bin/python | |
Please make sure you remove any previous custom paths from your /home/luke/.pydistutils.cfg file. | |
Installing setuptools, pip...done. | |
$ source env_p27/bin/activate | |
$ pip install Django==1.7.1 | |
Downloading/unpacking Django==1.7.1 | |
Using download cache from /home/luke/.pip/cache/https%3A%2F%2Fpypi.python.org%2Fpackages%2Fpy2.py3%2FD%2FDjango%2FDjango-1.7.1-py2.py3-none-any.whl | |
Installing collected packages: Django | |
Successfully installed Django | |
Cleaning up... | |
$ django-admin.py startproject migrationsbug | |
$ cd migrationsbug | |
$ ./manage.py startapp test1 | |
$ cat > test1/models.py | |
from django.db import models | |
class MyModel(models.Model): | |
name = models.CharField("First Name", max_length=255, blank=True) | |
^D | |
$ perl -n -i -p -e 's/INSTALLED_APPS = \(/INSTALLED_APPS = \("test1",/' migrationsbug/settings.py | |
$ ./manage.py makemigrations test1 | |
Migrations for 'test1': | |
0001_initial.py: | |
- Create model MyModel | |
$ cd ../ | |
$ deactivate | |
$ virtualenv --python=python3.4 env_p34 | |
Running virtualenv with interpreter /usr/bin/python3.4 | |
Using base prefix '/usr' | |
New python executable in env_p34/bin/python3.4 | |
Also creating executable in env_p34/bin/python | |
Please make sure you remove any previous custom paths from your /home/luke/.pydistutils.cfg file. | |
Installing setuptools, pip...done. | |
$ source env_p34/bin/activate | |
$ pip install Django==1.7.1 | |
Downloading/unpacking Django==1.7.1 | |
Using download cache from /home/luke/.pip/cache/https%3A%2F%2Fpypi.python.org%2Fpackages%2Fpy2.py3%2FD%2FDjango%2FDjango-1.7.1-py2.py3-none-any.whl | |
Installing collected packages: Django | |
Successfully installed Django | |
Cleaning up... | |
$ cd migrationsbug | |
$./manage.py makemigrations test1 | |
Migrations for 'test1': | |
0002_auto_20141211_1527.py: | |
- Alter field name on mymodel |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment