Limit batch size in bulk voucher creation (avoid problems with MySQL's max_packet_size)

This commit is contained in:
Raphael Michel
2021-01-28 12:43:26 +01:00
parent 3c85591568
commit ac7502b0a2
2 changed files with 2 additions and 2 deletions

View File

@@ -393,7 +393,7 @@ class VoucherBulkForm(VoucherForm):
data['bulk'] = True
del data['codes']
objs.append(obj)
Voucher.objects.bulk_create(objs)
Voucher.objects.bulk_create(objs, batch_size=200)
objs = []
for v in event.vouchers.filter(code__in=self.cleaned_data['codes']):
# We need to query them again as bulk_create does not fill in .pk values on databases