Key Error when trying to remove slug from my models

I am getting this error when I run migrations:

*old_field = model_state.fields.pop(name) KeyError: 'slug'*

I have no reference to a slug apart from in my migrations where I had added it then tried to removed it.

I am reluctant to delete any migrations but I cannot see another way of moving past this error.

I have found this code, in this file env\Lib\site-packages\django\db\migrations\state.py:

  def remove_field(self, app_label, model_name, name):
     model_key = app_label, model_name
     model_state = self.models[model_key]
     old_field = model_state.fields.pop(name)
     if self._relations is not None:
         self.resolve_model_field_relations(model_key, name, old_field)
     # Delay rendering of relationships if it's not a relational field.
     delay = not old_field.is_relation
     self.reload_model(*model_key, delay=delay)

Which is where the error is pointing but I don't think this should be touched.

I have tried to run a fake migration for the removal of the slug migration and although that goes through; the next time I ran a migration I got the same error again.

I am using a postgres DB.

Вернуться на верх