Changes between Initial Version and Version 3 of Ticket #27408
- Timestamp:
- Nov 1, 2016, 3:22:22 PM (8 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
Ticket #27408
- Property Triage Stage Unreviewed → Someday/Maybe
- Property Summary Multiple consecutive `bulk_create`s with FK. → Make QuerySet.bulk_create() populate fields on related models
-
Ticket #27408 – Description
initial v3 14 14 a = A() 15 15 b = B(a=a) # doesn't set `a_id`, since `a` has no id assigned yet. 16 A. bulk_create([a]) # sets `a`'s id.17 B. bulk_create([b]) # error!16 A.objects.bulk_create([a]) # sets `a`'s id. 17 B.objects.bulk_create([b]) # error! 18 18 }}} 19 19 The first `bulk_create` call sets the id on `a`, but `b.a_id` remains `None`. … … 35 35 bulk_a = [a] 36 36 bulk_b = [b] 37 A. bulk_create(bulk_a) # sets `a`'s id.37 A.objects.bulk_create(bulk_a) # sets `a`'s id. 38 38 fill_foreignkey_ids(bulk_b, ['a']) 39 B. bulk_create(bulk_b) # now it works. Lovely.39 B.objects.bulk_create(bulk_b) # now it works. Lovely. 40 40 }}} 41 41