Overcome the bulk_create() size limitation using SQLite
As of django 1.4, the newly introduced `bulk_create()` function has a strong limitation when using SQLite. Namely it causes an error if you want to create more than `999/F` objects, where `F` is the number of fields in the object type. The above `safe_bulk_create(objs)` function solves this issue by splitting the list of objects to appropriately sized bulks. This solution also works fine with other db backends, and according to my experiments, it causes no significant overhead comparing to using `bulk_create()` directly. For more details on the issue, see https://code.djangoproject.com/ticket/17788 Thanks to charettes for pointing out how to calculate the number of fields in an object.
- bulk_create