前提・実現したいこと
https://www.djangobrothers.com/tutorials/blog_app/first_app/ を見ながらdjangoの勉強をしているものです。
docker-composeを使ってその中で立てたwebコンテナ内でdjangoを使っています。
先ほどのページの最後のURL時にサイトが表示してくれません。
docker上の問題なのか手順の間違いなのかよくわかりません。
回答お願いします。
###ツリー
todo ➤ tree git:master* . ├── Dockerfile ├── composeexample │ ├── __init__.py │ ├── __init__.pyc │ ├── __pycache__ │ │ ├── __init__.cpython-37.pyc │ │ ├── settings.cpython-37.pyc │ │ ├── urls.cpython-37.pyc │ │ └── wsgi.cpython-37.pyc │ ├── settings.py │ ├── settings.pyc │ ├── urls.py │ ├── urls.pyc │ └── wsgi.py ├── docker-compose.yml ├── journals │ ├── __init__.py │ ├── __pycache__ │ │ ├── __init__.cpython-37.pyc │ │ ├── admin.cpython-37.pyc │ │ ├── models.cpython-37.pyc │ │ ├── urls.cpython-37.pyc │ │ └── views.cpython-37.pyc │ ├── admin.py │ ├── apps.py │ ├── migrations │ │ ├── __init__.py │ │ └── __pycache__ │ │ └── __init__.cpython-37.pyc │ ├── models.py │ ├── templates │ │ └── journals │ │ └── index.html │ ├── tests.py │ ├── urls.py │ └── views.py ├── manage.py ├── requirements.txt └── todo-github 9 directories, 30 files
###エラーコード
ModuleNotFoundError: No module named 'journals.urls'
該当のソースコード
journals/urls.py
journals/urls.py
1from django.urls import path 2from . import views 3 4app_name = 'journals' 5urlpatterns = [ 6 path('', views.index, name='index'), 7] 8
journals/views.py
journals/views.py
1from django.shortcuts import render 2 3 4def index(request): 5 return render(request, 'journals/index.html') 6
composeexample/urls.py
composeexample/urls.py
1from django.contrib import admin 2from django.urls import path, include 3 4urlpatterns = [ 5 path('admin/', admin.site.urls), 6 path('', include('journals.urls')), 7] 8
journals/templates/journals/index.html
journals/templates/journals/index.html
1<h1>ブログサイト</h1> 2<p>ここはトップページです!</p> 3
dockercompose.yml
dockercompose.yml
1version: '3' 2 3services: 4 db: 5 image: postgres 6 web: 7 build: . 8 command: python manage.py runserver 0.0.0.0:8000 9 volumes: 10 - .:/code 11 ports: 12 - "8000:8000" 13 depends_on: 14 - db 15
Dockerfile
FROM python:3 ENV PYTHONUNBUFFERED 1 RUN mkdir /code WORKDIR /code COPY requirements.txt /code/ RUN pip3 install -r requirements.txt COPY . /code/
補足情報(FW/ツールのバージョンなど)
python: 3.7.2
Django: 2.2
回答1件
あなたの回答
tips
プレビュー