Opened 5 years ago

Closed 5 years ago

Last modified 5 years ago

#31350 closed Bug (fixed)

.save() on list of entries will not work

Reported by: Shrikrishna Singh Owned by: Shrikrishna Singh
Component: Documentation Version: 3.0
Severity: Normal Keywords:
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: yes UI/UX: no

Description

I was going through the Database access optimization documentation.

And in the section [Update in bulk](https://docs.djangoproject.com/en/3.0/topics/db/optimization/#update-in-bulk), it is mentioned that:

entries = Entry.objects.bulk_create([
    Entry(headline='This is a test'),
    Entry(headline='This is only a test'),
])

After the bulk_create it possible to do:

entries[0].headline = 'This is not a test'
entries.save()
entries[1].headline = 'This is no longer a test'
entries.save()

Which doesn't seem right, as entries is list which will not have attribute save(). Instead it should be entries[0].save() and entries[1].save().

This is a very small mistake. But I am willing to send a PR if someone verify this issue.

Change History (4)

comment:1 by Claude Paroz, 5 years ago

Triage Stage: UnreviewedAccepted
Type: UncategorizedBug

That's right, we would welcome a patch!

comment:3 by GitHub <noreply@…>, 5 years ago

Resolution: fixed
Status: assignedclosed

In 3706286:

Fixed #31350 -- Fixed typo in docs/topics/db/optimization.txt.

comment:4 by Mariusz Felisiak <felisiak.mariusz@…>, 5 years ago

In 300bd06:

[3.0.x] Fixed #31350 -- Fixed typo in docs/topics/db/optimization.txt.

Backport of 370628673b98ada302c3930865c4bfde2d8ed5a1 from master

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