Update: Looks like it was an issue with the admin.py file custom code, I was following a code sample to display images inline which is causing the field to become required. Any suggestions on how to fix this? (See code below)
class AdminImageFieldWithThumbWidget(forms.widgets.FileInput): def __init__(self, thumb_width=50, thumb_height=50): self.width = thumb_width self.height = thumb_height super(AdminImageFieldWithThumbWidget, self).__init__({}) def render(self, name, value, attrs=None): thumb_html = '' if value and hasattr(value, 'url'): print(value) thumb_html = '<img src="/static/%s" width="%s" height="%s"/>' % (value.url, self.width, self.height) return mark_safe("%s%s" % (thumb_html, super(AdminImageFieldWithThumbWidget, self).render(name, value, attrs))) class CustomUserAdmin(UserAdmin): def formfield_for_dbfield(self, db_field, **kwargs): if db_field.name == 'picture': returnforms.ImageField(widget=AdminImageFieldWithThumbWidget(thumb_width = self.thumb_width, thumb_height = self.thumb_height)) return super(CustomUserAdmin,self).formfield_for_dbfield(db_field, **kwargs) NOTE: I tried adding null=True, blank=True to forms.ImageField however I get errors __init__() got an unexpected keyword argument so I guess I can't use them options. If I comment out the def formfield_for_dbfield(self, db_field, **kwargs): then the ImageField is not required as expected. On Thursday, December 6, 2012 2:47:57 PM UTC-8, Detectedstealth wrote: > > Hi, > > I have a picture for my custom user declared as follows: > > class CustomUser(AbstractBaseUser): > picture = models.ImageField(upload_to='profile_pictures', null=True, > blank=True) > > In admin I use the image > > class CustomUserAdmin(UserAdmin): > fieldsets( > ('Profile details', { > 'fields': ( > 'picture', > 'status', > ) > }), > ) > > Now for some reason even though I have null=True, blank=True in admin the > picture turns into a required field. Has anyone else experienced this or is > this expected behaviour ? > -- You received this message because you are subscribed to the Google Groups "Django users" group. To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/PlWOa--L5TAJ. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.