Hi all,

How to handle errors from different modules, for example CSV or
DATETIME in view?
I am trying to parse CSV content in my view after an uplod a file by
user.

def my_view(request):
    ...
    try:
        for row in csv.reader(request.FILES['file']):
            for i in range(0, len(row)):
                if not row[i].strip(): row[i] = 'None'
    except csv.Error, e:
        csv_error = e
     ....

In console scripts CSV exception works very well, but in Django can't
get it. The same story with DATETIME or some standartd python
operators:

try:
    discount = int(row[5])
except ValueError:
    csv_error = 'Bla Bla Bla'

How to handle this stuff?
--~--~---------~--~----~------------~-------~--~----~
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