I was doing a django project about handling problems request.data
and from.cleaned_data
. When a user enters only input fields, he sends a request to my server. Then the form class processes the request, except for processing the entered fields and does not return the entered fields from the built-in form fields.
This is the request data:
<QueryDict: {u'is_public': [u'True']}>
This is the cleared data from the class:
{'name': u'', 'devie_type': u'', 'is_public': True, 'serial_num': u'', 'is_online': False, 'operation_system': u''}
I know this is a type of dictionary. I hope to get their connection keys from them and the values of the cleared data. I expect him to return:
{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 are there any built-in functions for handling a federated dictionary in python?