Django:有效地将cleaned_data保存在会话中
在我的一个表单中,我正在处理表单数据并将其保存在会话变量中。
所以当我运行时
if locationForm.is_valid():
我执行
request.session['streetNumber'] = locationForm.cleaned_data['streetNumber']
request.session['postalCode'] = locationForm.cleaned_data['postalCode']
request.session['state'] = locationForm.cleaned_data['state']
request.session['country'] = locationForm.cleaned_data['country']
但这似乎效率很低。 我已经尝试过
request.session = locationForm.cleaned_data
,但似乎不起作用。
- 有没有更好的方法将所有 clean_data 信息存储在会话变量中?
- 是否有我应该注意的安全问题?
In one of my forms, I am processing the form data and save it in a session variable.
So when I run
if locationForm.is_valid():
I execute
request.session['streetNumber'] = locationForm.cleaned_data['streetNumber']
request.session['postalCode'] = locationForm.cleaned_data['postalCode']
request.session['state'] = locationForm.cleaned_data['state']
request.session['country'] = locationForm.cleaned_data['country']
But this seems very inefficient.
I have tried
request.session = locationForm.cleaned_data
but it does not seem to work.
- Is there any better way of storing all cleaned_data information in a session variable?
- Are there security concerns I should be aware off?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
怎么样
what about