mirror of
https://github.com/django/django.git
synced 2025-07-18 18:55:18 +00:00
Fixed #7830 -- Removed all of the remaining, deprecated, non-oldforms features:
* Support for representing files as strings was removed. Use `django.core.files.base.ContentFile` instead. * Support for representing uploaded files as dictionaries was removed. Use `django.core.files.uploadedfile.SimpleUploadedFile` instead. * The `filename`, `file_name`, `file_size`, and `chuck` properties of `UploadedFile` were removed. Use the `name`, `name`, `size`, and `chunks` properties instead, respectively. * The `get_FIELD_filename`, `get_FIELD_url`, `get_FIELD_size`, and `save_FIELD_file` methods for Models with `FileField` fields were removed. Instead, use the `path`, `url`, and `size` attributes and `save` method on the field itself, respectively. * The `get_FIELD_width` and `get_FIELD_height` methods for Models with `ImageField` fields were removed. Use the `width` and `height` attributes on the field itself instead. * The dispatcher `connect`, `disconnect`, `send`, and `sendExact` functions were removed. Use the signal object's own `connect`, `disconnect`, `send`, and `send` methods instead, respectively. * The `form_for_model` and `form_for_instance` functions were removed. Use a `ModelForm` subclass instead. * Support for importing `django.newforms` was removed. Use `django.forms` instead. * Support for importing `django.utils.images` was removed. Use `django.core.files.images` instead. * Support for the `follow` argument in the `create_object` and `update_object` generic views was removed. Use the `django.forms` package and the new `form_class` argument instead. git-svn-id: http://code.djangoproject.com/svn/django/trunk@8291 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
94e8f4fb35
commit
ef48a3e69c
17 changed files with 81 additions and 821 deletions
|
@ -192,10 +192,6 @@ class FileField(Field):
|
|||
def contribute_to_class(self, cls, name):
|
||||
super(FileField, self).contribute_to_class(cls, name)
|
||||
setattr(cls, self.name, FileDescriptor(self))
|
||||
setattr(cls, 'get_%s_filename' % self.name, curry(cls._get_FIELD_filename, field=self))
|
||||
setattr(cls, 'get_%s_url' % self.name, curry(cls._get_FIELD_url, field=self))
|
||||
setattr(cls, 'get_%s_size' % self.name, curry(cls._get_FIELD_size, field=self))
|
||||
setattr(cls, 'save_%s_file' % self.name, lambda instance, name, content, save=True: instance._save_FIELD_file(self, name, content, save))
|
||||
signals.post_delete.connect(self.delete_file, sender=cls)
|
||||
|
||||
def delete_file(self, instance, sender, **kwargs):
|
||||
|
@ -262,26 +258,15 @@ class FileField(Field):
|
|||
|
||||
class ImageFieldFile(ImageFile, FieldFile):
|
||||
def save(self, name, content, save=True):
|
||||
|
||||
if not hasattr(content, 'read'):
|
||||
import warnings
|
||||
warnings.warn(
|
||||
message = "Representing files as strings is deprecated." \
|
||||
"Use django.core.files.base.ContentFile instead.",
|
||||
category = DeprecationWarning,
|
||||
stacklevel = 2
|
||||
)
|
||||
content = ContentFile(content)
|
||||
|
||||
# Repopulate the image dimension cache.
|
||||
self._dimensions_cache = get_image_dimensions(content)
|
||||
|
||||
|
||||
# Update width/height fields, if needed
|
||||
if self.field.width_field:
|
||||
setattr(self.instance, self.field.width_field, self.width)
|
||||
if self.field.height_field:
|
||||
setattr(self.instance, self.field.height_field, self.height)
|
||||
|
||||
|
||||
super(ImageFieldFile, self).save(name, content, save)
|
||||
|
||||
def delete(self, save=True):
|
||||
|
@ -300,15 +285,6 @@ class ImageField(FileField):
|
|||
def get_manipulator_field_objs(self):
|
||||
return [oldforms.ImageUploadField, oldforms.HiddenField]
|
||||
|
||||
def contribute_to_class(self, cls, name):
|
||||
super(ImageField, self).contribute_to_class(cls, name)
|
||||
# Add get_BLAH_width and get_BLAH_height methods, but only if the
|
||||
# image field doesn't have width and height cache fields.
|
||||
if not self.width_field:
|
||||
setattr(cls, 'get_%s_width' % self.name, curry(cls._get_FIELD_width, field=self))
|
||||
if not self.height_field:
|
||||
setattr(cls, 'get_%s_height' % self.name, curry(cls._get_FIELD_height, field=self))
|
||||
|
||||
def formfield(self, **kwargs):
|
||||
defaults = {'form_class': forms.ImageField}
|
||||
defaults.update(kwargs)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue