Unfortunatelly I don't know how to get that traceback. If the exception happens from a model e.g.
try: b = Blog.objects.get(id = 1) except Blog.DoesNotExist: b = Blog(name = 'MyBlog') b.save() b = b.id It works very well. But following not: 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 or try: discount = int(row[5]) except ValueError: csv_error = 'Bla Bla Bla' When I am passing csv_error into my template I couldn't see this error in my browser. On Nov 9, 3:27 am, Daniel Roseman <[EMAIL PROTECTED]> wrote: > On Nov 9, 3:00 am, VP <[EMAIL PROTECTED]> wrote: > > > > > 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 handle it exactly like you are doing here. What is the problem? > Please post your traceback. > > Django is just Python, there should be no difference in the syntax. > > -- > DR. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---