20👍
✅
This happens to me all the time when using Postgres, and it’s really irritating.
You want:
from django.db import transaction
transaction.rollback()
Most of the time this is fine (and in my experience, it’s safe to ignore the TransactionManagementError
).
👤Seth
7👍
This is slightly better because you get no stack trace about TransactionManagementError
:
from django.db import transaction
transaction.rollback_unless_managed()
- South: run a migration for a column that is both unique and not null
- Django form with fields from two different models
- Running collectstatic on server : AttributeError: 'PosixPath' object has no attribute 'startswith'
- Django and MPTT – get only leaf nodes
Source:stackexchange.com