Answers for "django bulk update many to many"

1

django bulk update

objs = []
for person in p:
    obj = People.objects.get(email=person['email'])
    obj.birthday = person['birthday']
    objs.append(obj)
People.objects.bulk_update(objs, ['birthday'], batch_size=1000)
Posted by: Guest on April-01-2021
0

manytomany django add bulk create

# Use `MyModel.my_many_to_many.through.objects`
# "Tag.photos.through" => Model with 3 fields [ id, photo, tag ]
photo_tag_1 = Tag.photos.through(photo_id=1, tag_id=1)
photo_tag_2 = Tag.photos.through(photo_id=1, tag_id=2)
Tag.photos.through.objects.bulk_insert([photo_tag_1, photo_tag_2, ...])
Posted by: Guest on August-22-2021

Code answers related to "django bulk update many to many"

Python Answers by Framework

Browse Popular Code Answers by Language