Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7889129
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T06:01:00+00:00 2026-06-03T06:01:00+00:00

I am beginner to python Django . I have a string in json format

  • 0

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

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T06:01:02+00:00Added an answer on June 3, 2026 at 6:01 am

    An option you have here is to filter your dict down, and then use ** to unpack it as keyword arguments.

    user_fields = {"name", "pwd"}
    jsondict= {"name":"value","pwd":"pwdvalue","email":"email@gmail.com"}
    userdict = {key: value for (key, value) in jsondict.items() if key in user_fields}
    u = users(**userdict)
    

    We use a dict comprehension to filter out everything but the values we want (stored in the set user_fields).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

A python/django beginner's question: I have a datetime object (drive_date), a time object (start_time)
A beginner's Python question: I have a string with x number of sentences. How
I'm a beginner in Python. My problem is pretty simple. I have a string
As part of the last assignment in a beginner python programing class, I have
I am a beginner of python and have a question, very confusing for me.
I'm a beginner with both Python and RegEx, and I would like to know
I have some knowledge of Python 3 (I'm not a beginner, but I'm not
Sorry i'm a beginner in django and python..i create a project and i've a
I'm beginner in Python, and I have one question. Why does rounding a number
I am a beginner in django/python.I am using _meta to access the fields of

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.