When I python3 manage.py makemigrations
, I get bellow error:
...
File \"/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-
I also ran into this same error. In my case, I noticed that when I refactored the name of a model project-wide, it change a reference in such a way that does not work.
I'm cutting out some irrelevant code, but the original code looked like (note this is within an app named "blog"):
#model
class Category(models.Model):
pass
class Post(models.Model):
categories = models.ManyToManyField('blog.Category', related_name='posts')
The I chose to refactor Category
to Categorie
to test something on another page, and it changed the line
categories = models.ManyToManyField('blog.Category', related_name='posts')
to
categories = models.ManyToManyField('blog.models.Categorie', related_name='posts')
Which is in conflict with how django likes things, as stated in the error message
String model references must be of the form 'app_label.ModelName'
This was the only place I could find an issue, but it looks like the IDE (PyCharm) was trying to be helpful and created an error.