简体   繁体   中英

TypeError: __init__() got an unexpected keyword argument 'image_field'

I've profiles for clinics and would like to add images for each of them. I'm trying to use django-imaging and getting this error. I've followed the documentation and did the following:

settings.py

INSTALLED_APPS = (
    'm1',
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'django.contrib.sites',
    'django.contrib.sitemaps',
    'imaging',

models.py

from imaging.fields import ImagingField

class Clinic(models.Model):
    name = models.CharField(max_length=500)
    slug = models.CharField(max_length=200, unique = True)
    photos = models.ImagingField()

urls.py

url(r'^imaging/', include('imaging.urls')),

I then tried doing syncdb and got the following error:

Traceback (most recent call last):
  File "manage.py", line 10, in <module>
    execute_from_command_line(sys.argv)
  File "/Library/Python/2.7/site-packages/django/core/management/__init__.py", line 399, in execute_from_command_line
    utility.execute()
  File "/Library/Python/2.7/site-packages/django/core/management/__init__.py", line 392, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/Library/Python/2.7/site-packages/django/core/management/base.py", line 242, in run_from_argv
    self.execute(*args, **options.__dict__)
  File "/Library/Python/2.7/site-packages/django/core/management/base.py", line 284, in execute
    self.validate()
  File "/Library/Python/2.7/site-packages/django/core/management/base.py", line 310, in validate
    num_errors = get_validation_errors(s, app)
  File "/Library/Python/2.7/site-packages/django/core/management/validation.py", line 34, in get_validation_errors
    for (app_name, error) in get_app_errors().items():
  File "/Library/Python/2.7/site-packages/django/db/models/loading.py", line 196, in get_app_errors
    self._populate()
  File "/Library/Python/2.7/site-packages/django/db/models/loading.py", line 75, in _populate
    self.load_app(app_name, True)
  File "/Library/Python/2.7/site-packages/django/db/models/loading.py", line 99, in load_app
    models = import_module('%s.models' % app_name)
  File "/Library/Python/2.7/site-packages/django/utils/importlib.py", line 40, in import_module
    __import__(name)
  File "/Users/harisaghadi/code/meddy Production App/meddy1/models.py", line 10, in <module>
    from imaging.fields import ImagingField
  File "/Library/Python/2.7/site-packages/django_imaging-1.0.0-py2.7.egg/imaging/fields.py", line 6, in <module>
    from imaging.models import Image
  File "/Library/Python/2.7/site-packages/django_imaging-1.0.0-py2.7.egg/imaging/models.py", line 22, in <module>
    class Image(models.Model):
  File "/Library/Python/2.7/site-packages/django_imaging-1.0.0-py2.7.egg/imaging/models.py", line 31, in Image
    options={'quality':90}
TypeError: __init__() got an unexpected keyword argument 'image_field'

This is a bug in Django Imaging; see issue #11 in their tracker :

django-imagekit has been updated and the image_field kwarg has been renamed to source , its a bug in django-imaging and needs to be fixed.

That rename took place quite some time ago , in December 2012.

The work-around would be to downgrade Django-Imagekit to version 2.0.2, the last release with the field still named image_field . However, a project that hasn't been maintained to fix a field rename from 2 and a half years ago is perhaps not production worthy. Issue #11 was filed over a year ago and hasn't been fixed in all that time.

In your models.py, try
photos = ImagingField() instead of
photos = models.ImagingField()

Please read documentation https://github.com/pielgrzym/django-imaging

Add ImagingField to desired model from imaging.fields import ImagingField

class Somemodel(models.Model): photos = ImagingField()

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM