我的電話是Django的加入查詢ID
venues = ExtCalendar.objects.all()
,但我得到一個錯誤
(1054, "Unknown column 'ext_calendar.id' in 'field list'")
即使ext_calendar表中沒有此列
我的模型:
class ExtCalendar(models.Model):
source_id = models.CharField(max_length=255)
ext_type = models.CharField(max_length=32)
ext_id = models.CharField(max_length=255)
out_id = models.CharField(max_length=255, blank=True, null=True)
confidence = models.FloatField(blank=True, null=True)
data = models.CharField(max_length=8192, blank=True, null=True)
ext_name = models.CharField(max_length=255, blank=True, null=True)
out_name = models.CharField(max_length=255, blank=True, null=True)
last_out_id = models.CharField(max_length=32, blank=True, null=True)
status = models.CharField(max_length=10)
out_formatted = models.CharField(max_length=1024, blank=True, null=True)
ext_formatted = models.CharField(max_length=1024, blank=True, null=True)
class Meta:
db_table = 'ext_calendar'
unique_together = (('source_id', 'ext_type', 'ext_id'),)
def __unicode__(self):
return self.ext_id
返回值venues
是包含了不正確的查詢一個QuerySet:
SELECT `ext_calendar`.`id`, `ext_calendar`.`source_id`, `ext_calendar`.`ext_type`, `ext_calendar`.`ext_id`, `ext_calendar`.`out_id`, `ext_calendar`.`confidence`, `ext_calendar`.`data`, `ext_calendar`.`ext_name`, `ext_calendar`.`out_name`, `ext_calendar`.`last_out_id`, `ext_calendar`.`status`, `ext_calendar`.`out_formatted`, `ext_calendar`.`ext_formatted` FROM `ext_calendar`
那麼,如何從查詢中刪除ID?
你見過這些問題嗎? http://stackoverflow.com/questions/4192409/unknown-column-x-id-error-in-django-using-existing-db和http://stackoverflow.com/questions/3787237/django-models-1054- unknown-column-in-field-list – Shadow
嗯,我沒有同步問題,但其中的一個答案確實鏈接到了我正在尋找的內容,謝謝 – nic
實際上,我沒有那第一個鏈接,是的這個問題是那個人的複製 – nic