|
Re: clean_<fieldname>() doesn't handle images?: msg#02294DjangoUsers
Excellent! Thank you! On 31 jul, 14:42, Karen Tracey <kmtra...@xxxxxxxxx> wrote: > On Fri, Jul 31, 2009 at 3:18 AM, Martje <martijn.basti...@xxxxxxxxx> wrote: > > > I don't understand, sorry :$. Do you care to explain a little bit > > more? Or could you give an example? > > > I'm using the admin interface btw. > > You added a custom field clean method to your model definition. This has no > effect, as models (currently) don't support validation or cleaning. > Validation/cleaning is done for forms, so you need to add your custom field > clean method to the form used to upload your file. Admin supports this by > allowing you to specify the form it is to use for a model: > > http://docs.djangoproject.com/en/dev/ref/contrib/admin/#adding-custom... > > Karen > > > > > On 31 jul, 01:45, Karen Tracey <kmtra...@xxxxxxxxx> wrote: > > > On Thu, Jul 30, 2009 at 4:02 PM, Martje <martijn.basti...@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 -~----------~----~----~----~------~----~------~--~---
|
|
||||||||||||||||||||||||||
|
|
|
| News | Mail Home | sitemap | FAQ | advertise |