Ticket #6450: directory_creation.diff
File directory_creation.diff, 1.0 KB (added by , 17 years ago) |
---|
-
django/db/models/base.py
382 382 return os.path.getsize(self._get_FIELD_filename(field)) 383 383 384 384 def _save_FIELD_file(self, field, filename, raw_contents, save=True): 385 directory = field.get_directory_name() 386 try: # Create the date-based directory if it doesn't exist. 387 os.makedirs(os.path.join(settings.MEDIA_ROOT, directory)) 388 except OSError: # Directory probably already exists. 389 pass 385 directory = os.path.join(settings.MEDIA_ROOT, 386 field.get_directory_name()) 387 if not os.path.exists(directory): 388 os.makedirs(directory) 389 elif not os.path.isdir(directory): 390 raise IOError('%s exists and is not a directory' % directory) 390 391 filename = field.get_filename(filename) 391 392 392 393 # If the filename already exists, keep adding an underscore to the name of