Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/cocoa/3.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中验证和清理外部xml中的数据?_Python_Django_Django Forms - Fatal编程技术网

Python 如何在django中验证和清理外部xml中的数据?

Python 如何在django中验证和清理外部xml中的数据?,python,django,django-forms,Python,Django,Django Forms,我想从不受信任的外部rss源(通过feedparser)加载数据,并像django处理表单一样验证/清理数据。 怎么做? 我应该为它创建表单并从提要中的数据填充它吗? 如果是,怎么做? 通常是这样的: f= MyBogusForm(request.POST) 我把我的数据放在这张纸上 myDict={ 'title':'some title', 'date' : <time.struct_time>, 'author' : 'John Doe' 'content' : 'strin

我想从不受信任的外部rss源(通过feedparser)加载数据,并像django处理表单一样验证/清理数据。 怎么做? 我应该为它创建表单并从提要中的数据填充它吗? 如果是,怎么做? 通常是这样的:

f= MyBogusForm(request.POST)
我把我的数据放在这张纸上

myDict={
'title':'some title',
'date' : <time.struct_time>,
'author' : 'John Doe'
'content' : 'string with HTML that needs to be converted to text only'
}

使用解析器从XML文件中提取数据到dict,然后将该数据dict传递到表单

form = MyBogusForm(myDict)
if form.is_valid():
(...)