Ticket #3538: filefield_basename_trunk.diff
File filefield_basename_trunk.diff, 1.4 KB (added by , 18 years ago) |
---|
-
django/db/models/base.py
313 313 return os.path.join(settings.MEDIA_ROOT, getattr(self, field.attname)) 314 314 return '' 315 315 316 def _get_FIELD_basename(self, field): 317 if getattr(self, field.attname): # value is not blank 318 return os.path.basename( self._get_FIELD_filename(field) ) 319 return '' 320 316 321 def _get_FIELD_url(self, field): 317 322 if getattr(self, field.attname): # value is not blank 318 323 import urlparse -
django/db/models/fields/__init__.py
631 631 setattr(cls, 'get_%s_filename' % self.name, curry(cls._get_FIELD_filename, field=self)) 632 632 setattr(cls, 'get_%s_url' % self.name, curry(cls._get_FIELD_url, field=self)) 633 633 setattr(cls, 'get_%s_size' % self.name, curry(cls._get_FIELD_size, field=self)) 634 setattr(cls, 'get_%s_basename' % self.name, curry(cls._get_FIELD_basename, field=self)) 634 635 setattr(cls, 'save_%s_file' % self.name, lambda instance, filename, raw_contents: instance._save_FIELD_file(self, filename, raw_contents)) 635 636 dispatcher.connect(self.delete_file, signal=signals.post_delete, sender=cls) 636 637