Want to solve programming problems and get paid for it? If that sounds interesting to you then contact us.
To get rid of the your error, you need to roll back the last erroneous transaction after you have fixed your code.
e.g.
from django.db import transaction transaction.rollback()
Now you can use try-except to prevent the error from occurring:
from django.db import transaction, DatabaseError try: a.save( except DatabaseError: transaction.rollback()