logo       

Re: clean_<fieldname>() doesn't handle images?: msg#02228

DjangoUsers

Subject: Re: clean_<fieldname>() doesn't handle images?

On Thu, Jul 30, 2009 at 4:02 PM, Martje <martijn.bastiaan@xxxxxxxxx> wrote:

Hey,

I've got the following code in my models.py:

from django import forms
class Foto(models.Model):
   omschrijving = models.CharField(max_length=100)
   afbeelding = models.ImageField(upload_to='media/afbeeldingen/
header/fotos')

   def clean_afbeelding(self):
       raise forms.ValidationError("Never good! :-)")

Still, if I upload an image it validates, where it shouldn't, right?

Custom clean methods need to be added to the form you are using, not the model.

Karen

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django-users@xxxxxxxxxxxxxxxx
To unsubscribe from this group, send email to django-users+unsubscribe@xxxxxxxxxxxxxxxx
For more options, visit this group at http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Google Custom Search

News | Mail Home | sitemap | FAQ | advertise