我正在尝试此表中的记录,但失败了。请有人给我看一个示例,如何使用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)
答案 0 :(得分:1)
导航到应用程序的目录并运行:
python manage.py shell
然后导入模型:
from your_app_name.models import ApplicationStage
然后使用以下命令创建记录:
a = ApplicationStage(stage_id=1, leave_id=1, auth_id .......... and so on)
a.save()