[Fixed]-Django makemigrations AttributeError: 'str' object has no attribute '_meta'


There doesn’t seem to be a class named ImagePerson in that file which is what you are setting the through (the through table) to be in the M2M on Person.


Indentation problem on your Crew class?
Your str method here seems to be defined on the Meta:

class Crew(models.Model):
    name = models.CharField(max_length=256)
    members = models.ManyToManyField(
        through_fields=('crew', 'profile'),

    class Meta:
        db_table = 'Crew'

        def __str__(self):
            return '{0}: {1}'.format(self.__class__.__name__, self.name)

    def __repr__(self):
        return self.__str__()

Is that really what you’re after?


make sure you did python manage.py makemigrations and python manage.py migrate

if you already did it then check

in serializers.py

class Meta:
    model = 'bla bla' 
    fields = '__all__'

I got this error when i wrote model name in string ('') if you did same mistake then check and remove ''


For some people getting this error, don’t forget to add a newly created app into Django’s INSTALLED_APPS for your ManyToMany‘s through= intermediary model to be recognized.


If you get this error when registering your model in the admin.py then it is because of the follow:


and replace it with


TLDR: get rid of the the quotations in the model name

Leave a comment