coderholic / django-cities

Countries and cities of the world for Django projects
MIT License
927 stars 371 forks source link

Issue with migrations in Python3 #100

Closed cdvv7788 closed 8 years ago

cdvv7788 commented 9 years ago

When i run makemigrations Django is creating another migration field for this app. That may be an issue because my own migrations start depending on something external, so when i try to run my tests on my test server it won't find the dependency and crash.

The issue may be related to the type of some fields. For example we have for the initial migration:

migrations.CreateModel(
            name='City',
            fields=[
                ('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
                ('name', models.CharField(max_length=200, verbose_name=b'ascii name', db_index=True)),
                ('slug', models.CharField(max_length=200)),
                ('name_std', models.CharField(max_length=200, verbose_name=b'standard name', db_index=True)),
                ('location', django.contrib.gis.db.models.fields.PointField(srid=4326)),
                ('population', models.IntegerField()),
                ('elevation', models.IntegerField(null=True)),
                ('kind', models.CharField(max_length=10)),
                ('timezone', models.CharField(max_length=40)),
                ('alt_names', models.ManyToManyField(to='cities.AlternativeName')),
            ],
            options={
                'verbose_name_plural': 'cities',
            },
        ),

And for the migration that gets created afterwards:

migrations.AlterField(
            model_name='city',
            name='name',
            field=models.CharField(db_index=True, verbose_name='ascii name', max_length=200),
        ),
        migrations.AlterField(
            model_name='city',
            name='name_std',
            field=models.CharField(db_index=True, verbose_name='standard name', max_length=200),
        ),

I think Django is altering those fields to change them from byte type (b'ascii name' vs 'ascii name'). I tried this on Python2 and it is not happening. Any suggestions?

cdvv7788 commented 8 years ago

https://github.com/coderholic/django-cities/pull/102