mirror of
https://github.com/Hopiu/django-imagekit.git
synced 2026-04-09 07:51:00 +00:00
Now using contribute_to_class.
By creating the Descriptor using contribute_to_class (instead of in ImageModelBase's __init__), we take the first step towards eliminating the need to extend ImageModel at all.
This commit is contained in:
parent
82348d4931
commit
501d3c7ad3
2 changed files with 4 additions and 2 deletions
|
|
@ -8,7 +8,7 @@ from django.db.models.signals import post_delete
|
|||
from django.utils.html import conditional_escape as escape
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
|
||||
from imagekit.specs import ImageSpec, Descriptor
|
||||
from imagekit.specs import ImageSpec
|
||||
from imagekit.lib import *
|
||||
from imagekit.options import Options
|
||||
from imagekit.utils import img_to_fobj
|
||||
|
|
@ -46,7 +46,6 @@ class ImageModelBase(ModelBase):
|
|||
|
||||
for k, v in attrs.items():
|
||||
if isinstance(v, ImageSpec):
|
||||
setattr(self, k, Descriptor(v, k))
|
||||
specs.append(v)
|
||||
elif not default_image_field and isinstance(v, models.ImageField):
|
||||
default_image_field = k
|
||||
|
|
|
|||
|
|
@ -41,6 +41,9 @@ class ImageSpec(object):
|
|||
img.format = fmt
|
||||
return img, fmt
|
||||
|
||||
def contribute_to_class(self, cls, name):
|
||||
setattr(cls, name, Descriptor(self, name))
|
||||
|
||||
|
||||
class Accessor(object):
|
||||
def __init__(self, obj, spec, property_name):
|
||||
|
|
|
|||
Loading…
Reference in a new issue