Hello,

I'm trying to make a migration to change a field ("filter") from a 
ForeignKey to a CharField. The migration is as follow :

class Migration(migrations.Migration):

    operations = [
        migrations.AddField(
            model_name='Rendition',
            name='filter2',
            field=models.CharField(max_length=255, db_index=True),
        ),
        migrations.RunPython(forwards_data_migration, reverse_data_migration
),
        migrations.RemoveField(model_name='Rendition', name='filter'),
        migrations.DeleteModel('Filter'),
        migrations.RenameField(model_name='Rendition', old_name='filter2', 
new_name='filter'),
    ]

When running the migration, I have the following error:

django.core.exceptions.FieldDoesNotExist: Rendition has no field named 
> u'filter'
>

The error happens  during the RemoveField (migrations.RemoveField(model_name
='Rendition', name='filter')).

So, a couple questions:

* Is there a better way to change a field type (with data migration)?
* Why do I have this error, when my field is present?

The migration can be found there: 
https://github.com/Gagaro/wagtail/blob/02f4804b49d6f8b65ffb193d7a0dfc7872d323bd/wagtail/wagtailimages/migrations/0014_remove_filter_model.py
And the relevant model is 
there: 
https://github.com/Gagaro/wagtail/blob/02f4804b49d6f8b65ffb193d7a0dfc7872d323bd/wagtail/wagtailimages/models.py#L458-L516

Thanks

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/377e7587-05fe-4479-93e1-813be3609437%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to