0
我正在嘗試在此表中創建一條記錄,但失敗了。請有人告訴我一個例子,如何創建使用ApplicationStage.objects.create(...............)
如何使用此型號創建記錄
class ApplicationStage(Base):
stage_id = models.AutoField(primary_key=True)
leave_id = models.ForeignKey(Leave)
auth_id = models.ForeignKey(ApproveAuthority)
approve_status_id = models.ForeignKey(Status)
approve_total_day = models.PositiveIntegerField(default=0)
comment = models.TextField()
approved_time = models.DateTimeField(auto_now_add=True)
is_livedate = models.CharField(choices=(("yes","Yes"),
("no","No"),
),max_length=15)
「失敗」並沒有真正告訴我們很多。它爲什麼會失敗,出現什麼錯誤信息? – dutt 2013-05-13 07:24:40
您可以嘗試在模型實例上發出full_clean()方法,然後捕獲並打印該異常。可能會提供有關所得錯誤的更多信息:https://docs.djangoproject.com/en/dev/ref/models/instances/#django.db.models.Model.full_clean – 2013-05-13 07:53:28