Hi List, So I have this in models.py: class Job(models.Model):
jname = models.CharField(max_length=255) title = models.CharField(max_length=255, null=True, blank=True) file = models.FileField(upload_to=".") class JobForm(ModelForm): class Meta: model = Job fields = ('title', 'file') def clean_zipfile(self): if 'file' in self.cleaned_data: zip_file = self.cleaned_data['file'] if zip_file.get('content-type') != 'application/zip': msg = 'File upload must be a valid ZIP archive.' raise forms.ValidationError( msg ) else: try: zip = zipfile.ZipFile( StringIO( zip_file['content'] ) ) except: raise forms.ValidationError( "Could not unzip file." ) bad_file = zip.testzip() zip.close() del zip if bad_file: raise forms.ValidationError( msg ) return zip_file # Return the clean zip_file Where 'file' has to be a ZIP file. Obviously, JobForm is not working properly because I don't know how to return zip_file to 'file.clean()'. How can I do it? Many thanks in advance, Alan -- Alan Wilter S. da Silva, D.Sc. - CCPN Research Associate Department of Biochemistry, University of Cambridge. 80 Tennis Court Road, Cambridge CB2 1GA, UK. >>http://www.bio.cam.ac.uk/~awd28<< --~--~---------~--~----~------------~-------~--~----~ 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@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 -~----------~----~----~----~------~----~------~--~---