Django Models (1054, “Unknown column in 'field list'”)

后端 未结 13 1734
庸人自扰
庸人自扰 2020-12-08 13:18

No idea why this error is popping up. Here are the models I created -

from django.db import models
from django.contrib.auth.models import User

class Shows(m         


        
13条回答
  •  生来不讨喜
    2020-12-08 13:50

    I have met the same problems:

    First, run

    manage.py sqlall [appname]
    

    and you can find:

    `id` integer AUTO_INCREMENT NOT NULL PRIMARY KEY,
    

    and I add the column manual:

    ALTER TABLE tb_realtime_data ADD id integer AUTO_INCREMENT NOT NULL PRIMARY KEY FIRST;
    

    and then it worked.

    I think django will add the column called id itself.

    For convenience, each model is given an autoincrementing primary key field named id unless you explicitly specify primary_key=True on a field (see the section titled “AutoField” in Appendix A).

    you can click here for details.

    Good luck.

提交回复
热议问题