I'm using Django's command to perform some tasks involving database manipulation:
class SomeCommand(BaseCommand):
@transaction.atomic
def handle(self, *args, **options):
# Some stuff on the database
If an exception is thrown during execution of my program, @transaction.atomic
guarantees rollback. Can I force this behavior without throwing exception? Something like:
# Doing some stuff, changing objects
if some_condition:
# ABANDON ALL CHANGES AND RETURN
atomic
block.