News for hackers. Stuff that matters.
Re:Django 1.4 final released by jd on Friday March 23, 2012 @02:26PM (#3746460)
It's a great release, but bulk_insert is really really dangerous because it apparently doesn't call the save() method nor the pre_save or post_save signals.

I don't like this because a lot of us put validation logic in Model#save and use the signals to trigger the search indexer, and so forth. This behavior is definitely going to catch some people off guard and it's bound to lead to serious bugs.

I understand why they don't call Model#save for every object, but I think they should have introduced something like Model#validate which is called before every save (including the new bulk inserts) so you still get a place to put custom validation logic that you know will get called the moment something is placed in the database. So now inserts are faster but at the expense of correctness. I'm not convinced that's a good trade off.

Oh, and for some reason bulk updates are completely missing, even though it seems natural to add bulk_insert and bulk_update at the same time.

Re:Django 1.4 final released by ubernostrum on Friday March 23, 2012 @02:37PM (#3746507)
This is the correct behavior, really. Bulk insert is not for cases where you have complex per-record validation or processing logic that also needs to be run in the application layer. It's for "I have all this data ready to go, now just shove it in there as efficiently as possible". If you need to have validation and additional per-record processing, signals, etc., insert the objects through the ORM normally. Yes, it'll be slower, but that's the price you pay for doing per-record processing.
Re:Django 1.4 final released by notyourwork on Saturday March 24, 2012 @11:18AM (#3749556)
To add to this, you could write your own validation method for a model and have your model's save method call this.

When processing bulk data sets you can iterate over calling your own validation then perform bulk insert knowing its validating. And your save will still validate as before.

Re:Django 1.4 final released by amccloud on Friday March 23, 2012 @02:47PM (#3746547)
Re:Django 1.4 final released by joelhaasnoot on Friday March 23, 2012 @06:14PM (#3747624)
And bulk updating also doesn't run any signals or the save method...
Re:Django 1.4 final released by gtaylor on Friday March 23, 2012 @09:52PM (#3748190)
Nor should it. It's for inserting a bunch of stuff, really fast. You can just do normal saves if you want to call the save() method.