def atomic_save(model): try: with transaction.atomic(): model.save() except transaction.TransactionManagementError: # sqlite isn't happy model.save()