1 2 3 4 5 6 | def safe_bulk_create(objs):
"""Wrapper to overcome the size limitation of standard bulk_create()"""
if objs:
BULK_SIZE = 900/len(objs[0].__class__._meta.fields)
for i in range(0,len(objs),BULK_SIZE):
objs[0].__class__.objects.bulk_create(objs[i:i+BULK_SIZE])
|
More like this
- Bulk Insert - updated 5/9/2008 by coolie 5 years, 7 months ago
- Template tag to create a list from one or more variables and/or literals by davidchambers 2 years, 8 months ago
- Password Validation - Require Letters and Numbers - no regex by watchedman 1 year, 8 months ago
- PositionField by jpwatts 4 years, 10 months ago
- Significant digits filter by joelegner 4 years, 2 months ago
Comments