I was doing django project about processing request.data
and from.cleaned_data
issues. When user only inputs specify fields, it will send request to my server. Next, the form class process the request, except processing inputed fields and return no inputted fields from form built-in fields.
This is request data:
<QueryDict: {u'is_public': [u'True']}>
This is cleaned data from from class:
{'name': u'', 'devie_type': u'', 'is_public': True, 'serial_num': u'', 'is_online': False, 'operation_system': u''}
I know these are dictionary type. I hope getting their union keys of them and values of cleaned data. I expect that it returns:
{u'is_public': True}
This is my attempt:
a = {}
for k in request.data:
if k in the_form.cleaned_data:
a[k] = the_form.cleaned_data[k]
print a
Is it readable? or is there any built-in functions about processing union dictionary in python?