我想在单击“提交”按钮时记录提交日期。 该按钮链接到submit_report视图。其余的一切正常,但是没有记录日期
#models.ppy
class Report(models.Model):
createdOn = models.DateField(default=timezone.now)
SubmittedOn = models.DateField(auto_now=False, null=True,blank=True)
userName = models.CharField(max_length=250)
weekNo = models.CharField(max_length=20)
location = models.CharField(max_length=100)
projectCode = models.CharField(max_length=100)
totalAmount = MoneyField(max_digits=14, decimal_places=2,
default_currency='ugx')
flatsComment = models.CharField(max_length=300, default="")
financeComment = models.CharField(max_length=300, default="")
submitted = models.BooleanField(default=False)
#views.py
def submit_report(request, report_id):
report = get_object_or_404(Report,pk=report_id)
report.submitted = True
report.submittedOn = datetime.today()
report.save()
return redirect('prog:reports')