Ticket #7844: 7844.diff
File 7844.diff, 1.3 KB (added by , 16 years ago) |
---|
-
db/models/base.py
505 505 if filename is None: 506 506 filename = raw_field.file_name 507 507 508 filename = field.get_filename(filename )508 filename = field.get_filename(filename, directory) 509 509 510 510 # If the filename already exists, keep adding an underscore to the name 511 511 # of the file until the filename doesn't exist. -
db/models/fields/__init__.py
862 862 def get_directory_name(self): 863 863 return os.path.normpath(force_unicode(datetime.datetime.now().strftime(smart_str(self.upload_to)))) 864 864 865 def get_filename(self, filename ):865 def get_filename(self, filename, directory=None): 866 866 from django.utils.text import get_valid_filename 867 f = os.path.join(self.get_directory_name(), get_valid_filename(os.path.basename(filename))) 867 if not directory: 868 directory = self.get_directory_name() 869 f = os.path.join(directory, get_valid_filename(os.path.basename(filename))) 868 870 return os.path.normpath(f) 869 871 870 872 def save_form_data(self, instance, data):