Hello, I' ve an application where I upload a CSV file and save all its rows in a database. This is ok, but, at the moment, when I upload the file and it exists some error on it, it saves all rows until the wrong row. What I want to achieve is that if there is an error when I save, don't save anything. Is there any way to do that?
if formularioarchivomedios.is_valid(): reader = csv.DictReader(request.FILES['docfile'], delimiter=',') for row in reader: try: titulo=row['titulo'] url=row['url'] my_file = Medios(titulo=titulo, url=url) my_file.save() Thank you in advance! -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To post to this group, send email to django-users@googlegroups.com. Visit this group at https://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/908406c1-3f06-4889-953e-544a7a43afea%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.