#31350: .save() on list of entries will not work
-------------------------------------+-------------------------------------
               Reporter:             |          Owner:  Shrikrishna Singh
  Shrikrishna Singh                  |
                   Type:             |         Status:  assigned
  Uncategorized                      |
              Component:             |        Version:  3.0
  Documentation                      |
               Severity:  Normal     |       Keywords:
           Triage Stage:             |      Has patch:  0
  Unreviewed                         |
    Needs documentation:  0          |    Needs tests:  0
Patch needs improvement:  0          |  Easy pickings:  1
                  UI/UX:  0          |
-------------------------------------+-------------------------------------
 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.

-- 
Ticket URL: <https://code.djangoproject.com/ticket/31350>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/049.cdf1d5ee6dcd02e154e61c2a08a86ca7%40djangoproject.com.

Reply via email to