Exemple #1
0
 def form_valid(self, form):
     # This method is called when valid form data has been POSTed.
     #form.send_email()
     isvalid = super(ImportPageView, self).form_valid(form)
     fileup = handle_uploaded_file(self.request.FILES['file'], self.kwargs.get("app_label"), self.kwargs.get("model_name"))
     if fileup:
         messages.error(self.request, 'Dirty Data : ' + str(fileup))
         return HttpResponseRedirect(reverse('import_data', kwargs=self.kwargs))
     return isvalid
 def form_valid(self, form):
     # This method is called when valid form data has been POSTed.
     #form.send_email()
     isvalid = super(ImportPageView, self).form_valid(form)
     fileup = handle_uploaded_file(self.request.FILES['file'], self.kwargs.get("app_label"), self.kwargs.get("model_name"))
     if fileup:
         if type(fileup) == type('a string') or type(fileup) == type(u'some unicode'):
             messages.info(self.request, fileup, extra_tags='safe')
         else:
             for key, errors in fileup.message_dict.iteritems():
                 for error in errors:
                     messages.error(self.request, "Error on field '%s': %s" % (key, error))
         return HttpResponseRedirect(reverse('import_data', kwargs=self.kwargs))
     return isvalid