2016-01-21 58 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