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)
4

1 回答 1

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()
于 2013-05-13T11:47:01.963 回答