0

私はMac OSで動作するPythonのためにGoogleのアプリケーションエンジンの開発サーバーを使用しています。 私が実行しているプロジェクトは、djangaeとdjango restフレームワークを使用したappengine djangoプロジェクトです。django.test.clientのDjango Restフレームワークのインポートエラー

プロジェクトの内容はすべて正常に動作しますが、rest_frameworkに関連するインポートを宣言すると、現時点ではまだテストを実行していませんが、django.test.clientに関するエラーが発生します。

私がしようとしているのは、残りのフレームワークに関連してこのインポートやその他のインポートを行うと、from rest_framework.decoraters import api_viewです。

これは、残りのフレームワークに関連するすべてのインポートで発生するエラーです。

ERROR 2017-02-27 10:19:08,019 base.py:256] Internal Server Error: /_ah/warmup 
Traceback (most recent call last): 
File "/Users/MyUser/git/project-name/src/lib/django/core/handlers/base.py", line 223, in get_response 
    response = middleware_method(request, response) 
File "/Users/MyUser/git/project-name/src/core/middleware/url_definition.py", line 32, in process_response 
    response = redirect('%s/' % request.path) 
File "/Users/MyUser/git/project-name/src/lib/django/shortcuts.py", line 116, in redirect 
    return redirect_class(resolve_url(to, *args, **kwargs)) 
File "/Users/MyUser/git/project-name/src/lib/django/shortcuts.py", line 205, in resolve_url 
    return urlresolvers.reverse(to, args=args, kwargs=kwargs) 
File "/Users/MyUser/git/project-name/src/lib/django/core/urlresolvers.py", line 578, in reverse 
    return force_text(iri_to_uri(resolver._reverse_with_prefix(view, prefix, *args, **kwargs))) 
File "/Users/MyUser/git/project-name/src/lib/django/core/urlresolvers.py", line 432, in _reverse_with_prefix 
    self._populate() 
File "/Users/MyUser/git/project-name/src/lib/django/core/urlresolvers.py", line 284, in _populate 
    for pattern in reversed(self.url_patterns): 
File "/Users/MyUser/git/project-name/src/lib/django/core/urlresolvers.py", line 401, in url_patterns 
    patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module) 
File "/Users/MyUser/git/project-name/src/lib/django/core/urlresolvers.py", line 395, in urlconf_module 
    self._urlconf_module = import_module(self.urlconf_name) 
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/importlib/__init__.py", line 37, in import_module 
    __import__(name) 
File "/Users/MyUser/git/project-name/src/core/urls.py", line 34, in <module> 
    url(r'^', include('pages.urls'), name='pages.urls') 
File "/Users/MyUser/git/project-name/src/lib/django/conf/urls/__init__.py", line 33, in include 
    urlconf_module = import_module(urlconf_module) 
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/importlib/__init__.py", line 37, in import_module 
    __import__(name) 
File "/Users/MyUser/git/project-name/src/pages/urls.py", line 31, in <module> 
    url(r'^myapp/', include('pages.myapp.urls', namespace='rest_framework'), name="pages.myapp"), 
File "/Users/MyUser/git/project-name/src/lib/django/conf/urls/__init__.py", line 33, in include 
    urlconf_module = import_module(urlconf_module) 
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/importlib/__init__.py", line 37, in import_module 
    __import__(name) 
File "/Users/MyUser/git/project-name/src/pages/myapp/urls.py", line 4, in <module> 
    url(r'^finance/', include('pages.myapp.finance.urls'), name='pages.myapp.finance'), 
File "/Users/MyUser/git/project-name/src/lib/django/conf/urls/__init__.py", line 33, in include 
    urlconf_module = import_module(urlconf_module) 
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/importlib/__init__.py", line 37, in import_module 
    __import__(name) 
File "/Users/MyUser/git/project-name/src/pages/myapp/finance/urls.py", line 4, in <module> 
    url(r'^api/', include('pages.myapp.finance.api.urls'), name='pages.myapp.finance.api.urls'), 
File "/Users/MyUser/git/project-name/src/lib/django/conf/urls/__init__.py", line 33, in include 
    urlconf_module = import_module(urlconf_module) 
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/importlib/__init__.py", line 37, in import_module 
    __import__(name) 
File "/Users/MyUser/git/project-name/src/pages/myapp/finance/api/urls.py", line 4, in <module> 
    url(r'^service/', include('pages.myapp.finance.api.service.urls'), name='pages.myapp.finance.api.service'), 
File "/Users/MyUser/git/project-name/src/lib/django/conf/urls/__init__.py", line 33, in include 
    urlconf_module = import_module(urlconf_module) 
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/importlib/__init__.py", line 37, in import_module 
    __import__(name) 
File "/Users/MyUser/git/project-name/src/pages/myapp/finance/api/service/urls.py", line 8, in <module> 
    url(r'^user/', include('pages.myapp.finance.api.service.user.urls'), 
File "/Users/MyUser/git/project-name/src/lib/django/conf/urls/__init__.py", line 33, in include 
    urlconf_module = import_module(urlconf_module) 
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/importlib/__init__.py", line 37, in import_module 
    __import__(name) 
File "/Users/MyUser/git/project-name/src/pages/myapp/finance/api/service/user/urls.py", line 3, in <module> 
    from pages.myapp.finance.api.service.user import functions 
File "/Users/MyUser/git/project-name/src/pages/myapp/finance/api/service/user/functions.py", line 5, in <module> 
    from rest_framework.decorators import api_view 
File "/Users/MyUser/git/project-name/src/lib/rest_framework/decorators.py", line 15, in <module> 
    from rest_framework.views import APIView 
File "/Users/MyUser/git/project-name/src/lib/rest_framework/views.py", line 19, in <module> 
    from rest_framework.request import Request 
File "/Users/MyUser/git/project-name/src/lib/rest_framework/request.py", line 23, in <module> 
    from rest_framework.settings import api_settings 
File "/Users/MyUser/git/project-name/src/lib/rest_framework/settings.py", line 24, in <module> 
    from django.test.signals import setting_changed 
File "/Users/MyUser/git/project-name/src/lib/django/test/__init__.py", line 5, in <module> 
File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/tools/devappserver2/python/sandbox.py", line 999, in load_module 
    raise ImportError('No module named %s' % fullname) 
ImportError: No module named django.test.client 
+0

これらのライブラリはどのように含まれていますか?使用しているdjangoのバージョンにDRFで必要な 'django.test.client'がないようです:https://github.com/tomchristie/django-rest-framework/blob/1c437a793c3f3cedb1aa53f0cccec23a96cc3f34/rest_framework/settings .py#L23 – chachan

+0

@chachan私はdjangoをプロジェクトのinitのpythonパスに基本的な修正パスの設定で追加します。私が使っているdjangoのバージョンは 'Django 1.8.2'です。' django.test.clientしかし、関係なく、それはそうではないと言います。 –

答えて

2

アプリエンジンでこのようなインポートエラーに遭遇した場合には、app.yamlをして、あなたのskip_filesを確認してください。例えば

skip_files: 
    - ^(.*/)?.*/test/.*$ 

があなたのdevの環境にインポートできない「ジャンゴ/テスト」フォルダを作成し、フォルダがアプリエンジンに配備されることはありません。

関連する問題