I am facing this error (1054, "Unknown column 'id' in 'erp_app_invoice'")

hello i am newbie in this field, at the beginning everything's worked fine however i faced this error (1054, "Unknown column 'id' in 'erp_app_invoice'") after making some changes in my models.py. notice that i dont have id in my models.py as it should be generated automatically as far as i know

i tried adding id = models.AutoField(primary_key=True) but it didn't work due to the fact that i cant have 2 AutoFields, also tried to make it as CharField but that didn't work also

It looks like the issue is appearing because your database table erp_app_invoice is expecting a column named id, but it doesn't exist in your "models.py". Generally, Django creates an id field automatically as an AutoField when you do not specify one explicitly.

thank you i have solved this issue by dropping the table from MySQL workbench and re-run it again and migrate all data and it worked

Back to Top