I get "This field is required" error for image field on submitting a form in Form Wizard.
class SignupForm(forms.ModelForm): username = forms.CharField( label = _("Username*"), max_length = 30, widget = forms.TextInput() ) image = forms.ImageField(label = _("Profile picture*"), required=True) class Meta: model = Profile fields = ('name','gender','birth_date',)
This is my last form in form wizard. On submitting this form I got username and other fields in clean method but not the image. Is there a way to save image before validation of this form to avoid "This field is required" error?
To upload your images through Form Wizard you should change the file "django/contrib/formtools/wizard.py". These changes are mentioned in this Ticket code.djangoproject.com/ticket/7439. If you dont want to change djnago code then simply copy "formtools" folder into your apps then make changes there and instead of using:
from django.contrib.formtools.wizard import FormWizard
from formtools.wizard import FormWizard
Also set enctype="multipart/form-data" of your template form.