Unknown column 'boericke_joints.id' in 'field list

598 views
Skip to first unread message

Rishi Raj Jain

unread,
Jun 10, 2019, 7:18:50 AM6/10/19
to Django users
I'm using an already existing database in mysql. 
When I try to list the contents of the database it gives the following error:
(1054, "Unknown column 'boericke_joints.id' in 'field list'")
 The table doesn't contain an ID field. 

models.py looks like this ;

class BoerickeJoints(models.Model):
id = models.IntegerField(primary_key=True)
medicine = models.CharField(max_length=75, blank=True, null=True)
section = models.CharField(max_length=100, blank=True, null=True)
details = models.TextField(blank=True, null=True)

class Meta:
db_table = 'boericke_joints'

I added the id section and set it as the primary key, this is required by django apparently. but it still doesn't solve my issue.
Kindly help me in resolving this, thanks in advance.

James Farris

unread,
Jun 11, 2019, 12:24:12 PM6/11/19
to Django users
If the database was originally created by Django, it would have been built with an ID field. Django is confused because it can’t find that field in the database. If you added ID to the model, did you run python manage.py makemigrations and then python manage.py migrate
Reply all
Reply to author
Forward
0 new messages