def get_form_data_from_session(request, session_key):
"""Gets a dictionary from the session based on a key
and converts each key, list pair into a mutable QueryDict
so that it can be processed by a form as if it were post data
"""
raw_dict = request.session.get(session_key, {})
qdict = QueryDict('', mutable=True)
for key, items in raw_dict.items():
if not isinstance(items, list):
items = [items]
qdict.setlist(key, items)
return qdict
评论列表
文章目录