google-code-export / django-photologue

Automatically exported from code.google.com/p/django-photologue
BSD 3-Clause "New" or "Revised" License
0 stars 0 forks source link

Image file field not required #99

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
My users would like to be able to change a Photo title without upload again
the file.

I change image field making it non required in models.py:

    image = models.ImageField(_('image'), upload_to=get_storage_path,
              null=True, blank=True)

Next I added this in admin.py:

from django.forms.util import ErrorList

class PhotoForm(forms.ModelForm):
    class Meta:
        model = Photo
    def clean(self):
        if not self.cleaned_data['image'] and not self.instance.pk:
            self._errors["image"] = ErrorList([_(u"Choose photo file.")])
        return self.cleaned_data

class PhotoAdmin(admin.ModelAdmin):
    form = PhotoForm
    ...

Original issue reported on code.google.com by marcob...@gmail.com on 5 Feb 2009 at 11:27

GoogleCodeExporter commented 9 years ago
I don't think you need to have have these modifications in order change the 
title 
anymore using the latest Django code. Please let me know if this is not the 
case.

Original comment by justin.d...@gmail.com on 23 Jul 2009 at 5:35