Cipher
Cipher

Reputation: 2122

How to remove unwanted stuff from ImageField - Django

I want to remove currently and clear field from my django form.

forms.py

class MyUserProfileForm(forms.ModelForm):

    class Meta:
        model = UserProfile
        fields = ['user_phone','user_dob','user_gender', 'user_image', ]

I am using crispy_forms also

enter image description here

Upvotes: 1

Views: 49

Answers (1)

Daniel Roseman
Daniel Roseman

Reputation: 599530

That functionality is provided by ClearableFileInput. If you don't want it, use FileInput instead:

class MyUserProfileForm(forms.ModelForm):

    class Meta:
        model = UserProfile
        fields = ['user_phone','user_dob','user_gender', 'user_image', ]
        widgets = {'user_image': forms.FileInput}

Upvotes: 1

Related Questions