如何将日期字段的默认值设置为Null创建一个表项并在返回一本书时更新它?

时间:2016-09-24 23:09:45

标签: python django

如何在输入时将date_in字段设置为null,并将值更新为返回日期簿。

class Book_Loans(models.Model):
    Loan_id = models.AutoField(primary_key=True)
    Isbn = models.ForeignKey('Books')
    Card_id = models.ForeignKey('Borrower')
    Date_out = models.DateField(auto_now_add = True, auto_now = False)
    Due_date = models.DateField(default = get_deadline())
    Date_in = models.DateField(null = True,auto_now_add = False, auto_now = True)
    def __unicode__(self):
        return str(self.Loan_id)

1 个答案:

答案 0 :(得分:1)

设置 var doi1 = "CODE:"; doi1 += "SET !DATASOURCE links.csv" + "\n"; doi1 += "SET !DATASOURCE_COLUMNS 5" + "\n"; doi1 += "SET !DATASOURCE_LINE {{l}}" + "\n"; doi1 += "URL GOTO={{!COL1}}" + "\n"; doi1 += "WAIT SECONDS = 3" + "\n"; var doi2 = "CODE:"; doi2 += "SET !DATASOURCE links.csv" + "\n"; doi2 += "SET !DATASOURCE_COLUMNS 5" + "\n"; doi2 += "SET !DATASOURCE_LINE {{l}}" + "\n"; doi2 += "URL GOTO={{!COL2}}" + "\n"; doi2 += "WAIT SECONDS = 3" + "\n"; for(l=1;l<5;l++){ iimSet("l",l); iimPlay(doi1); iimPlay(doi2); } ,当创建或更新未指定Date_in值的实例时,该字段将保持为空。如果您需要Date_in作为表单上的可选字段,您可能还需要设置auto_now = False