1

i am using Django version 1.7 for an application, everything was running good in my developpement PC (i was runnin it using manage.py runserver command.

now i am trying to move it to a production server. in the production server, everything is still good when running the server using the manage.pycommand.

but accessing the application remotely (via apache2 & mod_wsgi), i get an RemovedInDjango19Warning Exception.

after looking for a solution all i could find is how to ignore theses warnings for manage.py which don't work for me and i don't know how to disable this warnings from wsgi ?

Traceback:

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.
Soufiaane
  • 1,737
  • 6
  • 24
  • 45
  • This traceback should simply be the result of running the app with the `-Wd` (display warnings) option, as described in the [release process docs](https://docs.djangoproject.com/en/1.7/internals/release-process/). Why can't you ignore / suppress it? – tutuDajuju Jan 21 '16 at 16:43
  • 1
    Is it possible for you to upgrade rest framework? The code that was causing the warning [has been fixed](https://github.com/tomchristie/django-rest-framework/commit/daf1d59d0f41d2ea89e0b996d22b5d4e84914fb5). – Alasdair Jan 21 '16 at 17:26
  • you need at least 3.1.0 – tutuDajuju Jan 21 '16 at 17:28
  • it worked, even though my code is broken now, is there any other way to solve this wihtout having to update the DRF ? at least temporarly? if not edit your Answer with this so i could accept it. – Soufiaane Jan 21 '16 at 17:38
  • The displayed exception may be caused by [`settings.TEMPLATE_DEBUG`](https://docs.djangoproject.com/en/1.7/ref/settings/#template-debug) being set to `True`, and the warning exception raised during template rendering. Can you check if setting to False removes the exception? – tutuDajuju Jan 21 '16 at 18:09
  • i reinstalled DRF v3.0.0 and set `settings.TEMPLATE_DEBUG` to False, still the same error, i guess i should adapt my code to DRF v3.1.0 – Soufiaane Jan 21 '16 at 19:23

3 Answers3

1

It's happening because the django.utils.importlib module is removed in Django 1.9, in favor of the importlib in the standard library. Django Rest Framework still uses it.

You can disable the warning by following the instructions on the accepted answer of this question -- How to suppress the deprecation warnings in Django?

Community
  • 1
  • 1
masnun
  • 11,635
  • 4
  • 39
  • 50
1

Finally, i ended up upgrading to Django1.9 and fixed the migration bugs.

Soufiaane
  • 1,737
  • 6
  • 24
  • 45
0

If you just want to silence the warning in mod_wsgi, you may add a configuration directive such as:

WSGIPythonWarnings ignore::DeprecationWarning::

See this blog entry, the release notes (point 15) and the original issue.

In essence, mod_wsgi had no equivalent to the -W control option, so a directive was added. The default must have been kept at "log everything" to be consistent across different wsgi apps.

tutuDajuju
  • 10,307
  • 6
  • 65
  • 88
  • 1
    i tried this, it's just ignoring theses warnings from showing up in the log fine, i'm stil getting this: [link](http://i.imgur.com/kBmMqro.png) – Soufiaane Jan 21 '16 at 17:02