gpt4 book ai didi

python - 编辑 django-cms 页面时出现 TransactionManagementError

转载 作者:行者123 更新时间:2023-11-28 17:40:42 25 4
gpt4 key购买 nike

我正要问一个问题并在发布之前找到了解决方案 :)

问题:

我正在尝试设置 django-cms对于一个简单的应用程序,当我尝试在前端编辑页面时遇到了 TransactionManagementError

django.db.transaction.TransactionManagementError
TransactionManagementError: This is forbidden when an 'atomic' block is active.

我目前正在使用 sqlite 并且我需要添加 'ATOMIC_REQUESTS': True 因为我得到了这个:

TransactionManagementError: Your database backend doesn't behave properly when autocommit is off. Turn it on before using 'atomic'.

数据库设置

DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
'ATOMIC_REQUESTS': True
}
}

我使用的版本

Django==1.6.5
django-cms==3.0.2

这是我得到的回溯:

django.db.transaction.TransactionManagementError
TransactionManagementError: This is forbidden when an 'atomic' block is active.

Traceback (most recent call last)
File "/Users/gableroux/.virtualenvs/adls-si/lib/python2.7/site-packages/django/contrib/staticfiles/handlers.py", line 67, in __call__
return self.application(environ, start_response)
File "/Users/gableroux/.virtualenvs/adls-si/lib/python2.7/site-packages/django/core/handlers/wsgi.py", line 206, in __call__
response = self.get_response(request)
File "/Users/gableroux/.virtualenvs/adls-si/lib/python2.7/site-packages/django/core/handlers/base.py", line 194, in get_response
response = self.handle_uncaught_exception(request, resolver, sys.exc_info())
File "/Users/gableroux/.virtualenvs/adls-si/lib/python2.7/site-packages/django/core/handlers/base.py", line 229, in handle_uncaught_exception
return debug.technical_500_response(request, *exc_info)
File "/Users/gableroux/.virtualenvs/adls-si/lib/python2.7/site-packages/django_extensions/management/technical_response.py", line 5, in null_technical_500_response
six.reraise(exc_type, exc_value, tb)
File "/Users/gableroux/.virtualenvs/adls-si/lib/python2.7/site-packages/django/core/handlers/base.py", line 112, in get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/Users/gableroux/.virtualenvs/adls-si/lib/python2.7/site-packages/django/db/transaction.py", line 371, in inner
return func(*args, **kwargs)
File "/Users/gableroux/.virtualenvs/adls-si/lib/python2.7/site-packages/cms/admin/settingsadmin.py", line 21, in wrapper
return self.admin_site.admin_view(view)(*args, **kwargs)
File "/Users/gableroux/.virtualenvs/adls-si/lib/python2.7/site-packages/django/utils/decorators.py", line 99, in _wrapped_view
response = view_func(request, *args, **kwargs)
File "/Users/gableroux/.virtualenvs/adls-si/lib/python2.7/site-packages/django/views/decorators/cache.py", line 52, in _wrapped_view_func
response = view_func(request, *args, **kwargs)
File "/Users/gableroux/.virtualenvs/adls-si/lib/python2.7/site-packages/django/contrib/admin/sites.py", line 198, in inner
return view(request, *args, **kwargs)
File "/Users/gableroux/.virtualenvs/adls-si/lib/python2.7/site-packages/django/utils/decorators.py", line 29, in _wrapper
return bound_func(*args, **kwargs)
File "/Users/gableroux/.virtualenvs/adls-si/lib/python2.7/site-packages/django/utils/decorators.py", line 99, in _wrapped_view
response = view_func(request, *args, **kwargs)
File "/Users/gableroux/.virtualenvs/adls-si/lib/python2.7/site-packages/django/utils/decorators.py", line 25, in bound_func
return func(self, *args2, **kwargs2)
File "/Users/gableroux/.virtualenvs/adls-si/lib/python2.7/site-packages/django/db/transaction.py", line 430, in inner
with self:
File "/Users/gableroux/.virtualenvs/adls-si/lib/python2.7/site-packages/django/db/transaction.py", line 422, in __enter__
self.entering(self.using)
File "/Users/gableroux/.virtualenvs/adls-si/lib/python2.7/site-packages/django/db/transaction.py", line 483, in entering
enter_transaction_management(using=using)
File "/Users/gableroux/.virtualenvs/adls-si/lib/python2.7/site-packages/django/db/transaction.py", line 70, in enter_transaction_management
get_connection(using).enter_transaction_management(managed, forced)
File "/Users/gableroux/.virtualenvs/adls-si/lib/python2.7/site-packages/django/db/backends/__init__.py", line 287, in enter_transaction_management
self.validate_no_atomic_block()
File "/Users/gableroux/.virtualenvs/adls-si/lib/python2.7/site-packages/django/db/backends/__init__.py", line 367, in validate_no_atomic_block
"This is forbidden when an 'atomic' block is active.")
TransactionManagementError: This is forbidden when an 'atomic' block is active.
The debugger caught an exception in your WSGI application. You can now look at the traceback which led to the error.

最佳答案

我只需要从 django-cms==3.0.2 更新至 django-cms==3.0.3问题消失了。这可以帮助某人。

我不确定到底是什么问题。我也得到 <class 'cms.models.titlemodels.Title'> has not been registered with django-reversion与回归,See this issue升级到 3.0.3 似乎也解决了这个问题。

关于python - 编辑 django-cms 页面时出现 TransactionManagementError,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24728638/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com