﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
9816	ModelForm with only FileField or ImageField can not pass validation	ogunes	nobody	"Hi.

I want to let my users can change their mugshot without updating their whole profile. When i have a form with only mugshot field, form never pass validaiton. If i add another field to that form it can pass validation now. My model and forms are below.

{{{
#!python
class Profile(models.Model):
    """"""
    Profile model
    
    """"""
    
    GENDER_CHOICES = (
        ('F', _('Female')),
        ('M', _('Male')),
    )

    user                = models.ForeignKey(User, unique=True, verbose_name=_('user'))
    
    mugshot             = models.ImageField(_('mugshot'), upload_to='uploads/mugshots', blank=True)
    birth_date          = models.DateField(_('birth date'), blank=True, null=True)
    gender              = models.CharField(_('gender'), choices=GENDER_CHOICES, max_length=1, null=True)
    occupation          = models.CharField(_('occupation'), max_length=32, blank=True)
    mobile              = PhoneNumberField(_('mobile'), blank=True)
}}}

This form never pass validation:
{{{
#!python
class MugshotForm(forms.ModelForm):
    mugshot             = forms.ImageField(required=True)
    
    class Meta:
        model = Profile
        fields = ['mugshot']
}}}

This form pass validation:
{{{
#!python
class MugshotForm(forms.ModelForm):
    gender              = forms.CharField(widget=forms.HiddenInput())
    mugshot             = forms.ImageField(required=True)
    
    class Meta:
        model = Profile
        fields = ['mugshot', 'gender']
}}}

Is this a bug or did i misunderstand something?"		closed	Forms	1.0		invalid	ModelForm ImageField validation	rokclimb15 Nicolás Miyasato	Accepted	0	0	0	0	0	0
