DjangoでパスをつないでHelloWorldを出力したいのですが、ブラウザで『http://127.0.0.1:8888/accounts/』をたたいても
表題のエラーが出てしまいます。
どこを改善したらよいかご教授願えますでしょうか。
tree
. └── mysite ├── accounts │ ├── admin.py │ ├── apps.py │ ├── __init__.py │ ├── migrations │ │ └── __init__.py │ ├── models.py │ ├── tests.py │ ├── urls.py │ └── views.py ├── config │ ├── __init__.py │ ├── __pycache__ │ │ ├── __init__.cpython-36.pyc │ │ └── settings.cpython-36.pyc │ ├── settings.py │ ├── settings.py_org │ ├── urls.py │ ├── wsgi.py │ └── wsgi.py_check ├── manage.py ├── static └── templates
/mysite/coufig/wsgi.py
""" WSGI config for config 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/2.2/howto/deployment/wsgi/ """ import os from django.core.wsgi import get_wsgi_application os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'config.settings') application = get_wsgi_application() ~
mysite/config/urls.py
from django.contrib import admin from django.urls import include, path urlpatterns = [ path('admin/', admin.site.urls), path('accounts/', include('accounts.urls')), ]
mysite/accounts/urls.py
from django.urls import path from . import views urlpatterns = [ path('', views.hello, name ='hello'),
vi mysite/accounts/views.py
from django.shortcuts import render from django.views import View from django.http import HttpResponse class HelloView(View): def get(self, request, *args, **kwargs): return HttpResponse('Hello, World!') hello = HelloView.as_view()
tail /var/log/httpd/error_log
ModuleNotFoundError: No module named 'config', referer: http://127.0.0.1:8888/accounts/
ちなみにwsgi.pyを下記に書き換えるとちゃんとhello!!が出力されているのでwsgi.pyまではパスは、
通っているかと思われます。
def application(environ, start_response): status = '200 OK' response_headers = [('Content-type', 'text/plain')] start_response(status, response_headers) return [b"hello!!"]
どこの設定のせいでaccountsの下のmoduleを読みこみに行ってしまっているのでしょうか。
わからないことだらけでお手数おかけしますがよろしくお願いします。
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。