Opened 6 years ago

Closed 6 years ago

#11749 closed (invalid)

QuerySet not autmatically evaluated on attribut update?

Reported by: gz Owned by: nobody
Component: Uncategorized Version: 1.1
Severity: Keywords: Database ORM QuerySet evaluation
Cc: gz Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description

Not evaluating QuerySets manually by using list() gives strange results while trying to update a model in the list:

my_list = Model.objects.all()
my_list[order].some_attribute = 12
my_list[index].save() # some_attribute is not updated!
# with my_list = list(Model.objects.all()) it works tough

I don't know if this is really a bug or intended behaviour?

Change History (2)

comment:1 in reply to: ↑ description Changed 6 years ago by gz

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset

Replying to gz:

Not evaluating QuerySets manually by using list() gives strange results while trying to update a model in the list:

my_list = Model.objects.all()
my_list[order].some_attribute = 12
my_list[index].save() # some_attribute is not updated!
# with my_list = list(Model.objects.all()) it works tough

I don't know if this is really a bug or intended behaviour?

order should be equal to index here, otherwise this example does not make sense

comment:2 Changed 6 years ago by ubernostrum

  • Resolution set to invalid
  • Status changed from new to closed

This is intended behavior; a QuerySet is not a list, and code which assumes it is will likely have difficulties.

Note: See TracTickets for help on using tickets.
Back to Top