[Django]-Django / mySQL – AttributeError: 'ForeignKey' object has no attribute 'IntegerField'

4👍

Your field named models shadows the models imported from Django. You can either rename the field:

other_name_for_models = models.ForeignKey('Model', db_column='models', blank=True, null=True)

or import the module with a different name

from django.db import models as django_models

class Machine(django_models.Model):
    models = django_models.ForeignKey('Model', db_column='model', blank=True, null=True)
👤Seb D.

Leave a comment