I am beginner to python Django . I have a string in json format , like
jsondict = {"name": "value", "pwd": "pwdvalue", "email": "email@gmail.com"}
i converted it to dict using json.loads(str)
From the above dict, i want to save only name,and pwd and many others except some keys. So, i am doing like this in the views :
u=users(name=jsondict['name'], pwd=jsondict['pwd'])
u.save()
Is my code having good quality ? or do i need to do that in any other way for having good quality .
In my question,automatic or manual in the sense, do i have to insert some dict directly or manullay have to do as i shown in the code ?
Will provide more information if necessary
Thanks
An option you have here is to filter your dict down, and then use
**to unpack it as keyword arguments.We use a dict comprehension to filter out everything but the values we want (stored in the set
user_fields).