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 8614825
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T05:12:55+00:00 2026-06-12T05:12:55+00:00

I want to update only one field in my model. However, I am getting

  • 0

I want to update only one field in my model. However, I am getting an error.

This is my model:

class People(models.Model):
    name = models.CharField(max_length=100)
    lastname = models.CharField(max_length=100)

class Salary(models.Model):
    id_of_people=models.ForeignKey(People)
    salary = models.IntegerField(required=False)

In views.py

-When I try this one to update :

def update(request):
a=Salary.objects.get(id_of_people_id=1)
a.salary=500
Salary().save()

My Error says:

IntegrityError  at/update
salary.id_of_people_id may not be NULL

and traceback indicates:

Salary().save()

-When I try this one :

def update(request):
a=Salary.objects.get(id_of_people_id=1)
a.salary=500
Salary().save(save_fields=['salary'])

-I get this error:

save() got an unexpected keyword argument 'save_fields'

Can you please help me to update only one field in my table ?

  • 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-12T05:12:57+00:00Added an answer on June 12, 2026 at 5:12 am

    In both of those cases you’ll want to call save on the model instance you’ve created, not the model class–that is, you should be saving a, not Salary:

    a.salary=500
    a.save()
    

    When you do Salary().save(), what’s happening is that you create a brand new, empty model instance, and then try to commit that to the database, rather than committing the one that you had just modified.

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

Sidebar

Related Questions

I want to update only one field in a mysql table. I have an
I have a model form that I use to update a model. class Turtle(models.Model):
Imagine you have this model: class Category(models.Model): node_id = models.IntegerField(primary_key = True) type_id =
I want to validate just one field of a form. Here is my model:
I am using jenkins with svn repository. Usually I want only to update svn
I want create module which update list of usb devices automatically (not only mass
I want to update the lastlogin column value .i wrote the code like this
My model is a simple parent/child representation looking like this public class Parent {
I know I can use $this->Model->save() to update a particular record if I pass
I have a deal model that contains two date field. First one is start_date

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.