wsgi.py tidak berfungsi di ubuntu apache2 mod_wsgi

Ini adalah file VirtualHost saya;

    Alias /static/ /home/ubuntu/app/boomset/static_root/
    <Directory /home/ubuntu/app/boomset/static_root>
            Require all granted
    </Directory>
    WSGIDaemonProcess boomset.com python-path=/home/ubuntu/app/boomset:/home/ubuntu/app/venv/lib/python2.7/site-packages
    WSGIProcessGroup boomset.com
    WSGIScriptAlias / /home/ubuntu/app/boomset/boomset/wsgi.py


    <Directory /home/ubuntu/app/boomset/boomset>
            <Files wsgi.py>
                    Require all granted
            </Files>
    </Directory>

dan ini file wsgi.py saya;

"""
WSGI config for boomset project.

It exposes the WSGI callable as a module-level variable named ``application``.

For more information on this file, see
https://docs.djangoproject.com/en/1.6/howto/deployment/wsgi/
"""

import os
import sys
import site

sys.path.append('/home/ubuntu/app')
sys.path.append('/home/ubuntu/app/boomset')
sys.path.append('/home/ubuntu/app/boomset/boomset')
site.addsitedir('/home/ubuntu/app/venv/lib/python2.7/site-packages')

from raven.contrib.django.raven_compat.middleware.wsgi import Sentry

os.environ.setdefault("DJANGO_SETTINGS_MODULE", "boomset.settings")

from django.core.wsgi import get_wsgi_application
application = Sentry(get_wsgi_application())

ini adalah file log kesalahan Apache saya. dekorator kerangka istirahat memberikan kesalahan tetapi itu tidak masuk akal bagi saya. Aku terjebak!

[Tue Jan 27 03:42:17.382849 2015] [:error] [pid 2926:tid 140170072491776] [remote 64.79.151.225:16875]   File "/home/ubuntu/app/venv/lib/python2.7/site-packages/django/core/handlers/wsgi.py", line 206, in __call__
[Tue Jan 27 03:42:17.382920 2015] [:error] [pid 2926:tid 140170072491776] [remote 64.79.151.225:16875]     response = self.get_response(request)
[Tue Jan 27 03:42:17.382933 2015] [:error] [pid 2926:tid 140170072491776] [remote 64.79.151.225:16875]   File "/home/ubuntu/app/venv/lib/python2.7/site-packages/django/core/handlers/base.py", line 196, in get_response
[Tue Jan 27 03:42:17.387153 2015] [:error] [pid 2926:tid 140170072491776] [remote 64.79.151.225:16875]     response = self.handle_uncaught_exception(request, resolver, sys.exc_info())
[Tue Jan 27 03:42:17.387171 2015] [:error] [pid 2926:tid 140170072491776] [remote 64.79.151.225:16875]   File "/home/ubuntu/app/venv/lib/python2.7/site-packages/django/core/handlers/base.py", line 234, in handle_uncaught_exception

....

[Tue Jan 27 03:42:17.387714 2015] [:error] [pid 2926:tid 140170072491776] [remote 64.79.151.225:16875]     from rest_framework.decorators import action
[Tue Jan 27 03:42:17.387733 2015] [:error] [pid 2926:tid 140170072491776] [remote 64.79.151.225:16875] ImportError: cannot import name action

person user3461147    schedule 27.01.2015    source sumber


Jawaban (1)


Apakah mungkin kode sumber Anda bergantung pada Django REST 2.x tetapi menginstal versi 3.x? Karena metode action dihapus dari versi 3.x dan ini mungkin menjadi penyebab kesalahan impor. Anda dapat memeriksa tautan di bawah ini

https://github.com/tomchristie/django-rest-framework/blob/version-2.4.x/rest_framework/decorators.py

https://github.com/tomchristie/django-rest-framework/blob/master/rest_framework/decorators.py

Saya belum pernah menggunakan site.addsitedir dan Sentry(get_wsgi_application()) sebelumnya tetapi semuanya tampak baik-baik saja.

person brsbilgic    schedule 27.01.2015