Skip to content

Use different widget #10

@erwinelling

Description

@erwinelling

I am using ImageField on a model and use a Modelform to generate a form.

If I understand correctly, the form automatically uses the widget provided by this package, being ClearableFileInput, with and added preview of the image.

I'd like to use a different widget in my form, but overriding the widget on the form level, fails because it still seems to run this function:

def with_preview_and_ppoi(widget, **attrs):
    return type(
        str("%sWithPreviewAndPPOI" % widget.__name__),
        (PreviewAndPPOIMixin, widget),
        dict(attrs, __module__="imagefield.widgets"),
    )

I tried using just forms.ClearableFileInput, and get the error:
'ClearableFileInput' object has no attribute 'name'

I'm having difficulties wrapping my head around where to change or alter the widget. Would you be able to give me some pointers? If you think this hasn't got enough to do with this particular package, I would understand, but I'm not sure.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions