python – 导入错误:没有名为transaction的模块
发布时间:2020-12-20 12:09:19 所属栏目:Python 来源:网络整理
导读:我在 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.contri
我在
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. 在简单的视图显示一切正常,但当我尝试在浏览器中打开网址时,我在浏览器中收到此错误:
和控制台中的此错误: 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",in import_module __import__(name) ImportError: No module named transaction [13/Oct/2015 09:03:51] "GET /favicon.ico HTTP/1.1" 500 59 解决方法
在Django 1.6中的
transaction middleware was deprecated,并在Django 1.8中删除.从中间件类中删除以下行.
'django.middleware.transaction.TransactionMiddleware', 您可以使用新功能 有关更多信息,请查看解释changes to transactions的文档部分. (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |