Django:持续时间

时间:2016-02-02 09:11:06

标签: django timefield

目前,我使用 django 1.4.8 ,我的模型中有以下两个字段:

app.factory("srvRandom", ["$interval", function ($interval) {

    var randomCreator,
        randomN = 0;          // Change

    return {
        start: function () {
            console.log("START")
            randomCreator = $interval(function () {
                randomN = Math.random() * 10;
            }, 2000);
        },
        stop: function () {
            console.log("STOP")
            $interval.cancel(randomCreator);
        },
        randomN: randomN          // Change
    };
}]);

我尝试添加一个字段来指示持续时间

class Event(models.Model):
...
    start = models.DateTimeField(_(u"départ"))
    end = models.DateTimeField(_('fin'))

但我收到了管理员的错误

     start = models.DateTimeField(_(u"départ"))
     time_delay = models.TimeField(_(u"Time_delay"), auto_now_add=True, blank=True, default=datetime.datetime.utcnow)

我的管理员:

'EventAdmin.fieldsets[0][1]['fields']' refers to field 'time_delay' that is missing from the form

...

这是什么问题

1 个答案:

答案 0 :(得分:1)

您为time_delay字段设置了Option Explicit Sub ClearDuplicates() Dim i As Long Dim lRng As Long lRng = Range("A65536").End(xlUp).Row For i = lRng To 1 Step -1 If Application.WorksheetFunction.CountIf(Range("A1:A" & i), _ Range("A" & i).Value) > 1 Then Range("A" & i).ClearContents End If Next i End Sub ,因此django不会将此字段添加到表单

auto_now_add = True