hi,

It is mush easier then my approach. Thanks a lot!

On Fri, Nov 28, 2008 at 9:28 PM, redbaron <[EMAIL PROTECTED]> wrote:
>
>
> My current solution is.
>
> 1. Define new model Batches:
>
> class Batches(models.Model):
>  batchfile = model.FileField(upload_to="noop")
>
> 2. In admin.py define new form with custom validators:
>
> class BatchUploadForm(forms.ModelFormi):
>    class Meta:
>        model = Batches
>
>    def clean_batchfile(self):
>        data = self.cleaned_data['batchfile'].read() #here we've got
> uploaded file content
>        ret = your_processing_routine(data) #if file is wrong
> processing returns error message
>        if ret:
>            raise forms.ValidationError(ret)
>
>
> 3. Register customized ModelAdmin for Batches:
>
> class BatchesAdmin(admin.ModelAdmin):
>    form = BatchUploadForm #here we've replaced default form to our
> one
>
>    def save_model(self, request, obj, form, change):
>        pass #nothing save to base actually
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to