2016-01-21 54 views
1

我使用的Django 1.7版的应用程序时, 一切都运行在我DEVELOPPEMENT PC好(我使用manage.py runserver命令现在奔跑吧。Django1.7“RemovedInDjango19Warning”使用Apache与mod_wsgi的

我试图将它移动到生产服务器。 生产服务器,一切使用manage.py命令运行服务器的时候还是不错的。

但(通过的Apache2 & mod_wsgi的)远程访问应用程序,我得到一个RemovedInDjango19Warning异常。

寻找解决方案后,我能找到的是如何忽略manage.py这些不适用于我的警告,我不知道如何从wsgi禁用此警告?

回溯:

Environment: 


Request Method: GET 
Request URL: http://192.168.0.17/ 

Django Version: 1.7.1 
Python Version: 3.4.3 
Installed Applications: 
('django.contrib.admin', 
'django.contrib.auth', 
'django.contrib.contenttypes', 
'django.contrib.sessions', 
'django.contrib.messages', 
'django.contrib.staticfiles', 
'django_extensions', 
'rest_framework', 
'rest_framework_nested', 
'django_gravatar', 
'authentication', 
'djcelery', 
'job', 
'seed', 
'proxies', 
'emails') 
Installed Middleware: 
('django.contrib.sessions.middleware.SessionMiddleware', 
'django.middleware.common.CommonMiddleware', 
'django.middleware.csrf.CsrfViewMiddleware', 
'django.contrib.auth.middleware.AuthenticationMiddleware', 
'django.contrib.auth.middleware.SessionAuthenticationMiddleware', 
'django.contrib.messages.middleware.MessageMiddleware', 
'django.middleware.clickjacking.XFrameOptionsMiddleware') 


Traceback: 
File "/usr/local/lib/python3.4/dist-packages/django/core/handlers/base.py" in get_response 
    98.     resolver_match = resolver.resolve(request.path_info) 
File "/usr/local/lib/python3.4/dist-packages/django/core/urlresolvers.py" in resolve 
    343.    for pattern in self.url_patterns: 
File "/usr/local/lib/python3.4/dist-packages/django/core/urlresolvers.py" in url_patterns 
    372.   patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module) 
File "/usr/local/lib/python3.4/dist-packages/django/core/urlresolvers.py" in urlconf_module 
    366.    self._urlconf_module = import_module(self.urlconf_name) 
File "/usr/lib/python3.4/importlib/__init__.py" in import_module 
    109.  return _bootstrap._gcd_import(name[level:], package, level) 
File "/var/www/cvc.ma/CapValue/urls.py" in <module> 
    6.      url(r'^api/v1/auth/', include('authentication.urls')), 
File "/usr/local/lib/python3.4/dist-packages/django/conf/urls/__init__.py" in include 
    28.   urlconf_module = import_module(urlconf_module) 
File "/usr/lib/python3.4/importlib/__init__.py" in import_module 
    109.  return _bootstrap._gcd_import(name[level:], package, level) 
File "/var/www/cvc.ma/authentication/urls.py" in <module> 
    2. from authentication.views import LoginView, LogoutView 
File "/var/www/cvc.ma/authentication/views.py" in <module> 
    4. from rest_framework import permissions, viewsets, status, views 
File "/usr/local/lib/python3.4/dist-packages/rest_framework/viewsets.py" in <module> 
    24. from rest_framework import views, generics, mixins 
File "/usr/local/lib/python3.4/dist-packages/rest_framework/views.py" in <module> 
    11. from rest_framework.request import Request 
File "/usr/local/lib/python3.4/dist-packages/rest_framework/request.py" in <module> 
    20. from rest_framework.settings import api_settings 
File "/usr/local/lib/python3.4/dist-packages/rest_framework/settings.py" in <module> 
    22. from django.utils import importlib, six 
File "/usr/local/lib/python3.4/dist-packages/django/utils/importlib.py" in <module> 
    10.  RemovedInDjango19Warning, stacklevel=2) 

Exception Type: RemovedInDjango19Warning at/
Exception Value: django.utils.importlib will be removed in Django 1.9. 
+0

此回溯应该只是使用'-Wd'(显示警告)选项运行应用程序的结果,如[发布流程文档](https://docs.djangoproject.com/en/1.7/)中所述内部/释放过程/)。你为什么不能忽视/压制它? – tutuDajuju

+1

您可以升级rest框架吗?导致警告的代码[已被修复](https://github.com/tomchristie/django-rest-framework/commit/daf1d59d0f41d2ea89e0b996d22b5d4e84914fb5)。 – Alasdair

+0

你需要至少3.1.0 – tutuDajuju

回答

1

最后,我结束了升级到Django1.9并修复了迁移错误。

1

,它的发生是因为django.utils.importlib模块在标准库在Django 1.9去除,有利于importlib的。 Django Rest Framework仍然使用它。

您可以通过以下对这个问题的答案接受指令禁用警告 - How to suppress the deprecation warnings in Django?

+0

,但它不是为我工作, 可能是apache2服务正在使用-Wd选项执行我的应用程序。 如果这是真的,我不知道如何禁用此 – Soufiaane

+0

你做了更改后重新启动服务器? – masnun

+0

当然,如果有疑问,即使重启整个系统。 – Soufiaane

0

如果你只想沉默预警mod_wsgi,您可以添加一个配置指令,例如:

WSGIPythonWarnings ignore::DeprecationWarning:: 

请参阅this blog entry,release notes (point 15)the original issue

实质上,mod_wsgi没有等效于-W控制选项,因此添加了指令。默认值必须保持在“记录所有内容”,以便在不同的wsgi应用程序中保持一致。

+1

我试过了,它只是忽略了这些警告从日志中显示出来, 我很难得到这个: [链接](http://i.imgur.com/kBmMqro.png) – Soufiaane