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

  • Home
  • SEARCH
  • 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 7931327
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T20:41:08+00:00 2026-06-03T20:41:08+00:00

How come it is not possible to save the entry when I fetch it

  • 0

How come it is not possible to save the entry when I fetch it by using filter?
It works if I fetch it with get.

I need to use filter since I’m using the serializer to return a JSON object. And Django’s serializer doesn’t like if it is not a QuerySet.

message = UserMessage.objects.filter(id=request.GET['msg_id'])
message[0].read = True
message[0].save()
  • 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-03T20:41:09+00:00Added an answer on June 3, 2026 at 8:41 pm

    Unless the message is evaluated and thus cached, the message[0] always hits DB, for example

    >>> qs = User.objects.all()
    >>> qs[0] is qs[0]
    False
    >>> bool(qs) # evaluate, len(qs) or iterating on qs also do
    >>> qs[0] is qs[0]
    True
    

    you could assign it to variable

    message = UserMessage.objects.filter(id=request.GET['msg_id'])[0]
    message.read = True
    message.save()
    

    or use update directly, as jpic suggested:

    UserMessage.objects.filter(id=request.GET['msg_id']).update(read=True)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using Git for version control and unlike SVN I have not come across
Every solution I come up with is not thread save. def uuid(cls,db): u =
How come http://www.zolomon.com/wptj/wp-content/themes/default/polaroid.swf works perfectly but not when implemented at http://www.zolomon.com/wptj/?page_id=8 ? The code
I am trying to save drafts using NSUserDefaults but I am not sure if
How come this is not possible? I am getting illegal start of expression. (s1.charAt(i)
I've installed SlimDX but the assembly reference does not come up as a choice
I have come across the following jQuery code but could not understand it. What
I'm not too used to ORM mapping, having come from a PHP background. I'm
Not totally sure how to approach this. I've researched a bit but I've come
I really like parser combinators but I'm not happy with the solution I've come

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.