Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

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, ...])
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #manytomany #django #add #bulk #create
ADD COMMENT
Topic
Name
7+1 =