我正在尝试将一个项目从Django 1.5.5更新到Django 1.6,然而我无论做什么都会遇到这个错误。
Traceback (most recent call last):
File "project/virtualenv/lib/python2.7/site-packages/django/core/handlers/base.py", line 114, in get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "project/virtualenv/lib/python2.7/site-packages/django/contrib/admin/sites.py", line 215, in wrapper
return self.admin_view(view, cacheable)(*args, **kwargs)
File "project/virtualenv/lib/python2.7/site-packages/django/utils/decorators.py", line 99, in _wrapped_view
response = view_func(request, *args, **kwargs)
File "project/virtualenv/lib/python2.7/site-packages/django/views/decorators/cache.py", line 52, in _wrapped_view_func
response = view_func(request, *args, **kwargs)
File "project/virtualenv/lib/python2.7/site-packages/django/contrib/admin/sites.py", line 197, in inner
return self.login(request)
File "project/virtualenv/lib/python2.7/site-packages/django/views/decorators/cache.py", line 52, in _wrapped_view_func
response = view_func(request, *args, **kwargs)
File "project/virtualenv/lib/python2.7/site-packages/django/contrib/admin/sites.py", line 330, in login
return login(request, **defaults)
File "project/virtualenv/lib/python2.7/site-packages/django/views/decorators/debug.py", line 75, in sensitive_post_parameters_wrapper
return view(request, *args, **kwargs)
File "project/virtualenv/lib/python2.7/site-packages/django/utils/decorators.py", line 99, in _wrapped_view
response = view_func(request, *args, **kwargs)
File "project/virtualenv/lib/python2.7/site-packages/django/views/decorators/cache.py", line 52, in _wrapped_view_func
response = view_func(request, *args, **kwargs)
File "project/virtualenv/lib/python2.7/site-packages/django/contrib/auth/views.py", line 43, in login
auth_login(request, form.get_user())
File "project/virtualenv/lib/python2.7/site-packages/django/contrib/auth/__init__.py", line 83, in login
request.session.cycle_key()
File "project/virtualenv/lib/python2.7/site-packages/django/contrib/sessions/backends/base.py", line 277, in cycle_key
self.create()
File "project/virtualenv/lib/python2.7/site-packages/django/contrib/sessions/backends/db.py", line 40, in create
self.save(must_create=True)
File "project/virtualenv/lib/python2.7/site-packages/django/contrib/sessions/backends/db.py", line 62, in save
with transaction.atomic(using=using):
File "project/virtualenv/lib/python2.7/site-packages/django/db/transaction.py", line 244, in __enter__
"Your database backend doesn't behave properly when "
TransactionManagementError: Your database backend doesn't behave properly when autocommit is off. Turn it on before using 'atomic'.
我已经从MIDDLEWARE_CLASSES
中删除了TransactionMiddleware
,并将其替换为ATOMIC_REQUESTS = True
。(即使我不执行此步骤,仍会出现相同的错误)
能有人解释一下这是什么原因吗?
forwards
函数中,我会这样做:orm["auth.Group"].objects.get_or_create(name="blah")
。等有机会了,我会尝试你的建议。 - SunnySydeUp