Python Django ArrayField。如何通过django admin节省嵌套的时间数组?

Python Django ArrayField。如何通过django admin节省嵌套的时间数组?,python,django,postgresql,django-admin,django-orm,Python,Django,Postgresql,Django Admin,Django Orm,几个月前我已经问过这个问题了 这个问题很愚蠢,但我找不到解决办法。从简单表单文本字段保存嵌套时间数组的有效格式是什么 我有这样的ArrayField: schedule = ArrayField( ArrayField( ArrayField( models.TimeField(null=True), ), size=2, null=True,

几个月前我已经问过这个问题了

这个问题很愚蠢,但我找不到解决办法。从简单表单文本字段保存嵌套时间数组的有效格式是什么

我有这样的ArrayField:

schedule = ArrayField(
        ArrayField(
            ArrayField(
                models.TimeField(null=True),
            ),
            size=2,
            null=True,
        ),
        size=7,
        null=True,
        blank=True,
    )
当我试图从django admin保存它时,如:

((09:00, 09:00), (09:00, 09:00), (09:00, 09:00), (09:00, 09:00), (09:00, 9:00), (9:00, 9:00), (9:00, 9:00))
我有错误

Item 0 in the array did not validate: Item 0 in the array did not validate: Item 0 in the array did not validate: Enter a valid time.
Item 1 in the array did not validate: Item 0 in the array did not validate: Item 0 in the array did not validate: Enter a valid time.
Item 2 in the array did not validate: Item 0 in the array did not validate: Item 0 in the array did not validate: Enter a valid time.
Item 3 in the array did not validate: Item 0 in the array did not validate: Item 0 in the array did not validate: Enter a valid time.
Item 4 in the array did not validate: Item 0 in the array did not validate: Item 0 in the array did not validate: Enter a valid time.
Item 5 in the array did not validate: Item 0 in the array did not validate: Item 0 in the array did not validate: Enter a valid time.
Item 6 in the array did not validate: Item 0 in the array did not validate: Item 0 in the array did not validate: Enter a valid time.
Item 7 in the array did not validate: Item 0 in the array did not validate: Item 0 in the array did not validate: Enter a valid time.
Item 8 in the array did not validate: Item 0 in the array did not validate: Item 0 in the array did not validate: Enter a valid time.
Item 9 in the array did not validate: Item 0 in the array did not validate: Item 0 in the array did not validate: Enter a valid time.
Item 10 in the array did not validate: Item 0 in the array did not validate: Item 0 in the array did not validate: Enter a valid time.
Item 11 in the array did not validate: Item 0 in the array did not validate: Item 0 in the array did not validate: Enter a valid time.
Item 12 in the array did not validate: Item 0 in the array did not validate: Item 0 in the array did not validate: Enter a valid time.
Item 13 in the array did not validate: Item 0 in the array did not validate: Item 0 in the array did not validate: Enter a valid time.

我已经尝试过一些其他格式,如:[[“09:00”,“09:00”]]或(('09:00”,“09:00'))或纯文本,如“09:00”,“09:00”,但它不起作用。

您的
计划
字段是一个三维数组,但您传递的是一个二维数组

计划
字段定义应为:

schedule = ArrayField(
    ArrayField(
        models.TimeField(null=True),
        size=2,
        null=True,
    ),
    size=7,
    null=True,
    blank=True,
)

另外,默认的Django小部件不支持嵌套数组。您必须创建自己的小部件。

注意,这是正确的,但在models.py中更改后,我仍然无法保存数组并获得相同的错误消息。再进一步考虑,django默认表单字段和/或小部件不支持嵌套数组似乎是合理的。您必须创建自己的formfield/widget来处理您的
时间表
字段。你能告诉我你对Django的看法吗?我将尝试编写这样的小部件来完成我的回答。