Code

Ticket #1564: manipulators.diff

File manipulators.diff, 898 bytes (added by oyvind@…, 8 years ago)

Diff to save file before saving in manipulator

Line 
1Index: django/db/models/manipulators.py
2===================================================================
3--- django/db/models/manipulators.py    (revision 2602)
4+++ django/db/models/manipulators.py    (working copy)
5@@ -98,13 +98,14 @@
6 
7         # First, save the basic object itself.
8         new_object = self.model(**params)
9-        new_object.save()
10 
11-        # Now that the object's been saved, save any uploaded files.
12+        # Now that the object's not yet been saved, save any uploaded files.
13         for f in self.opts.fields:
14             if isinstance(f, FileField):
15                 f.save_file(new_data, new_object, self.change and self.original_object or None, self.change, rel=False)
16-
17+               
18+       new_object.save()
19+       
20         # Calculate which primary fields have changed.
21         if self.change:
22             self.fields_added, self.fields_changed, self.fields_deleted = [], [], []