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