Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/332.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python Django-自动将清理后的数据分配给数据库字段_Python_Django - Fatal编程技术网

Python Django-自动将清理后的数据分配给数据库字段

Python Django-自动将清理后的数据分配给数据库字段,python,django,Python,Django,我处理表单的通常方式如下: contact = Contact( name=form.cleaned_data['name'], email=form.cleaned_data['email'], message=form.cleaned_data['message'], newsletter=form.cleaned_data['newsletter']

我处理表单的通常方式如下:

contact = Contact(
                name=form.cleaned_data['name'],
                email=form.cleaned_data['email'],
                message=form.cleaned_data['message'],
                newsletter=form.cleaned_data['newsletter']
            )
但对于长格式,这显然是一项乏味的任务。我想知道是否有任何Django方法我可能错过了,它可以自动将清理后的数据分配给数据库表中相应的列,而不必手动分配它们

有什么想法吗?提前谢谢

Django为您提供了一个专门为这项任务设计的解决方案