Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

214
Views
How to select a record and update it with a single set of queries in Django?

How do I run update and select statements in the same queryset instead of having to do two queries: one to select the object and one to update the object?


The equivalent in SQL would be something like:

 update my_table set field_1 = 'some value' where pk_field = some_value
over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

You can do it in the following way:

 MyModel.objects.filter(pk=some_value).update(field1='some value')

If you want to go deeper into the subject, I leave you this link: https://docs.djangoproject.com/en/3.1/topics/db/queries/#topics-db-queries-update

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!