Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions admin_tabs/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,13 @@
from django.contrib.admin.options import csrf_protect_m
from django.db import transaction

# django 1.6, 1.5 and 1.4 supports
try:
atomic_decorator = transaction.atomic
except AttributeError:
atomic_decorator = transaction.commit_on_success


class AdminCol(object):
"""
One column in the admin pages.
Expand Down Expand Up @@ -339,7 +346,7 @@ def get_form(self, request, obj=None, **kwargs):
return super(TabbedModelAdmin, self).get_form(request, obj, **kwargs)

@csrf_protect_m
@transaction.commit_on_success
@atomic_decorator
def change_view(self, request, object_id, form_url='', extra_context=None):
if extra_context is None:
extra_context = {}
Expand All @@ -353,7 +360,7 @@ def change_view(self, request, object_id, form_url='', extra_context=None):
return super(TabbedModelAdmin, self).change_view(request, object_id, extra_context=extra_context)

@csrf_protect_m
@transaction.commit_on_success
@atomic_decorator
def add_view(self, request, form_url='', extra_context=None):
if extra_context is None:
extra_context = {}
Expand Down