导入错误:没有名为transaction的模块

时间:2022-06-05 18:10:22

i'm working in a django project, migrating from 1.5 version to 1.8 version, i have some problems and this is one. When i execute python manage.py runserver, returns me:

我在django项目中工作,从1.5版本迁移到1.8版本,我有一些问题,这是一个。当我执行python manage.py runserver时,返回我:

/usr/local/lib/python2.7/dist-packages/django/contrib/admin/models.py:28: RemovedInDjango19Warning: Model class django.contrib.admin.models.LogEntry doesn't declare an explicit app_label and either isn't in an application in INSTALLED_APPS or else was imported before its application was loaded. This will no longer be supported in Django 1.9.
  class LogEntry(models.Model):
/usr/local/lib/python2.7/dist-packages/django/contrib/admin/models.py:28: RemovedInDjango19Warning: Model class django.contrib.admin.models.LogEntry doesn't declare an explicit app_label and either isn't in an application in INSTALLED_APPS or else was imported before its application was loaded. This will no longer be supported in Django 1.9.
  class LogEntry(models.Model):
Performing system checks...
System check identified no issues (0 silenced).
You have unapplied migrations; your app may not work properly until they are applied.
Run 'python manage.py migrate' to apply them.
octubre 13, 2015 - 08:57:36
Django version 1.8.4, using settings 'spid.settings'
Starting development server at http://127.0.0.1:8000/
Quit the server with CONTROL-C.

at simple view appears all is working, but when i try to open the url in my browser, i receive this error in the browser:

在简单的视图看起来一切正常,但当我尝试在浏览器中打开网址时,我在浏览器中收到此错误:

A server error occurred. Please contact the administrator.

发生服务器错误。请联系管理员。

and this error in the console:

和控制台中的此错误:

Traceback (most recent call last):
  File "/usr/lib/python2.7/wsgiref/handlers.py", line 85, in run
    self.result = application(self.environ, self.start_response)
  File "/usr/local/lib/python2.7/dist-packages/django/contrib/staticfiles/handlers.py", line 63, in __call__
    return self.application(environ, start_response)
  File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/wsgi.py", line 170, in __call__
    self.load_middleware()
  File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/base.py", line 50, in load_middleware
    mw_class = import_string(middleware_path)
  File "/usr/local/lib/python2.7/dist-packages/django/utils/module_loading.py", line 26, in import_string
    module = import_module(module_path)
  File "/usr/lib/python2.7/importlib/__init__.py", line 37, in import_module
    __import__(name)
ImportError: No module named transaction
[13/Oct/2015 09:03:51] "GET /spid/ HTTP/1.1" 500 59
Traceback (most recent call last):
  File "/usr/lib/python2.7/wsgiref/handlers.py", line 85, in run
    self.result = application(self.environ, self.start_response)
  File "/usr/local/lib/python2.7/dist-packages/django/contrib/staticfiles/handlers.py", line 63, in __call__
    return self.application(environ, start_response)
  File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/wsgi.py", line 170, in __call__
    self.load_middleware()
  File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/base.py", line 50, in load_middleware
    mw_class = import_string(middleware_path)
  File "/usr/local/lib/python2.7/dist-packages/django/utils/module_loading.py", line 26, in import_string
    module = import_module(module_path)
  File "/usr/lib/python2.7/importlib/__init__.py", line 37, in import_module
    __import__(name)
ImportError: No module named transaction
[13/Oct/2015 09:03:51] "GET /favicon.ico HTTP/1.1" 500 59

1 个解决方案

#1


9  

The transaction middleware was deprecated in Django 1.6, and removed in Django 1.8. Remove the following line from your middleware classes.

事务中间件在Django 1.6中已弃用,在Django 1.8中被删除。从中间件类中删除以下行。

'django.middleware.transaction.TransactionMiddleware', 

There is a new feature ATOMIC_REQUESTS which you can use instead.

ATOMIC_REQUESTS有一个新功能,您可以使用它。

For more information, have a look at the section of the docs which explains the changes to transactions.

有关更多信息,请查看解释事务更改的文档部分。

#1


9  

The transaction middleware was deprecated in Django 1.6, and removed in Django 1.8. Remove the following line from your middleware classes.

事务中间件在Django 1.6中已弃用,在Django 1.8中被删除。从中间件类中删除以下行。

'django.middleware.transaction.TransactionMiddleware', 

There is a new feature ATOMIC_REQUESTS which you can use instead.

ATOMIC_REQUESTS有一个新功能,您可以使用它。

For more information, have a look at the section of the docs which explains the changes to transactions.

有关更多信息,请查看解释事务更改的文档部分。