credits_total,credits_buy,time_credits_buy,credits_before_day,time_sign_before_day
主键是:user_id,也是外键,关联了visitors...id = models.IntegerField('id主键', primary_key=True, auto_created=True)
# user_id = models.ForeignKey(Visitors...,on_delete=models.CASCADE,primary_key=True)
user = models.ForeignKey(Visitors,on_delete=models.CASCADE...class Meta():
# credits,为数据库中的表名
db_table = 'credits'
注意:
注释中,# user_id = models.ForeignKey(Visitors...解决方案:把user_id 改成user即可,user = models.ForeignKey(Visitors,on_delete=models.CASCADE,primary_key=True),正确如下图