Issues in Applying migration after renaming models

Hello Everyones,
I hope your journey with the beautiful Djano is going well,
Im working in a project, and I made two new models working with them in views and some other functions… etc, today the lead asked me to change names of both models I made.

So when Im doing it I cant apply migrations I made, instead I got this Error:

ValueError: Related model 'organisation.Groups' cannot be resolved

and I think this Error is linked to this ligne, which says it cant delete this model

migrations.DeleteModel(
            name='Groups',
        ),

Greets world

Renaming models needs to be handled very carefully. The basic approach may end up with a loss of data.
Make sure you update your any models that refer to the to the main model.

In your error, it looks like your have a ForiegnKey to the Groups model that did not get migrated.

edit: correct a word

1 Like