Closed willhunger closed 6 years ago
Sorry, but this is way to vague and unspecific to help you.
From what I can see you try to override the widget on a Model and not on a Form which is not the way how things work. (https://docs.djangoproject.com/en/1.11/topics/forms/modelforms/#overriding-the-default-fields)
Traceback (most recent call last): File "/usr/local/lib/python3.5/dist-packages/django/utils/autoreload.py", line 226, in wrapper fn(*args, kwargs) File "/usr/local/lib/python3.5/dist-packages/django/core/management/commands/runserver.py", line 113, in inner_run autoreload.raise_last_exception() File "/usr/local/lib/python3.5/dist-packages/django/utils/autoreload.py", line 249, in raise_last_exception six.reraise(_exception) File "/usr/local/lib/python3.5/dist-packages/django/utils/six.py", line 685, in reraise raise value.with_traceback(tb) File "/usr/local/lib/python3.5/dist-packages/django/utils/autoreload.py", line 226, in wrapper fn(args, kwargs) File "/usr/local/lib/python3.5/dist-packages/django/init.py", line 27, in setup apps.populate(settings.INSTALLED_APPS) File "/usr/local/lib/python3.5/dist-packages/django/apps/registry.py", line 108, in populate app_config.import_models(all_models) File "/usr/local/lib/python3.5/dist-packages/django/apps/config.py", line 199, in import_models self.models_module = import_module(models_module_name) File "/usr/lib/python3.5/importlib/init.py", line 126, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "", line 986, in _gcd_import
File "", line 969, in _find_and_load
File "", line 958, in _find_and_load_unlocked
File "", line 673, in _load_unlocked
File "", line 673, in exec_module
File "", line 222, in _call_with_frames_removed
File "/home/will/PycharmProjects/hnwcd/women/models.py", line 343, in
class img(models.Model):
File "/usr/local/lib/python3.5/dist-packages/django/db/models/base.py", line 119, in new
new_class.add_to_class('_meta', Options(meta, app_label))
File "/usr/local/lib/python3.5/dist-packages/django/db/models/base.py", line 316, in add_to_class
value.contribute_to_class(cls, name)
File "/usr/local/lib/python3.5/dist-packages/django/db/models/options.py", line 206, in contribute_to_class
raise TypeError("'class Meta' got invalid attribute(s): %s" % ','.join(meta_attrs.keys()))
TypeError: 'class Meta' got invalid attribute(s): widgets
When i add meta ,i got a TypeError
class Meta: widgets = { 'image': ImageCropWidget, }
I also want to ask ,how to save the image after cropping in folder? When i have a look at mysql database, i found the cropping field is the value of croping image.