class NewAdmin(admin.ModelAdmin): fields = ( ('City','Age'), 'Sex', 'Image' ) formfield_overrides = { models.ImageField : {'widget' : ViewImageField} }
TypeError at /admin/main/profile/1/change/__init__() takes at least 4 arguments (1 given)Request Method: GETRequest URL: http://127.0.0.1:8000/admin/main/profile/1/change/Django Version: 1.11.17Exception Type: TypeErrorException Value: __init__() takes at least 4 arguments (1 given)Exception Location: D:\django\hello\lib\site-packages\django\forms\fields.py in __init__, line 96Python Executable: D:\django\hello\Scripts\python.exe
А как выглядит сам ViewImageField?
class ViewImageField(BoundField): def __init__(self, form, field, name, textvalue = 'textvalue', css_cls = 'upload_image'): if textvalue == 'textvalue': textvalue = 'Define ' + textvalue + ' in ' + self.__class__.__name__ self.text = textvalue self.css_class = 'class=' + css_cls super(ViewImageField, self).__init__(form, field, name) def label_tag(self, contents=None, attrs=None, label_suffix=None):