models.py
from django.db import models from django.contrib.postgres.fields import ArrayFeild class TestInfoUser(models.Model): modify = ArrayField( models.CharField( max_length=128, ), size=20, null=True, blank=True, verbose_name='用户信息' )
shell 脚本
# 数组套元组
>>> TestInfoUser.objects.create(modify=[('name', '1312454999@qq.com'),('lanlan', 'td68123299@163.com')]) <TestInfoUser: TestInfoUser object (2)> >>> TestInfoUser.objects.create(modify=[('name', '1312454888@qq.com'),('lanlan', 'td68123999@163.com'), ('honghong', '1312454298@qq.com'), ('kkkk', '77777777777')]) <TestInfoUser: TestInfoUser object (3)> >>> TestInfoUser.objects.create(modify=[('name', '1312454888@qq.com'),('lanlan', 'td68123999@163.com'), ('honghong', '1312454298@qq.com'), ('kkkk', '77777777777', 'ddddd','ddddddddddd')]) <TestInfoUser: TestInfoUser object (4)>
# 数组套字典
TestInfoUser.objects.create(modify=[{'name': "echo", 'email': '1312454999@qq.com'}, {'name': 'echo1', 'email':'122344'}])
<TestInfoUser: TestInfoUser object (5)>