前提・実現したいこと
https://www.djangobrothers.com/tutorials/blog_app/first_app/ を見ながらdjangoの勉強をしているものです。
docker-composeを使ってその中で立てたwebコンテナ内でdjangoを使っています。
先ほどのページの最後のURL時にサイトが表示してくれません。
docker上の問題なのか手順の間違いなのかよくわかりません。
回答お願いします。
以上が前回の質問なんですが、この後続きを行なってviews.pyでクエリセットとhtmlに値の表示を入力しただけなのですが、新しく追加したところだけ表示されません。
docer-compose downやdocker-compose up、python manage.py migrateなどを何回か行なっても変わりません。
回答よろしくお願いします。
###python manage.py showmigrations結果
以下のように初期のマイグレーションはできています。
しかし、journalのマイグレーションファイルが作られていないのが謎です。
root@05a668d65769:/code# python manage.py showmigrations admin [X] 0001_initial [X] 0002_logentry_remove_auto_add [X] 0003_logentry_add_action_flag_choices auth [X] 0001_initial [X] 0002_alter_permission_name_max_length [X] 0003_alter_user_email_max_length [X] 0004_alter_user_username_opts [X] 0005_alter_user_last_login_null [X] 0006_require_contenttypes_0002 [X] 0007_alter_validators_add_error_messages [X] 0008_alter_user_username_max_length [X] 0009_alter_user_last_name_max_length [X] 0010_alter_group_name_max_length [X] 0011_update_proxy_permissions contenttypes [X] 0001_initial [X] 0002_remove_content_type_name journals [X] 0001_initial [X] 0002_auto_20190420_0834 sessions [X] 0001_initial
###ツリー
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
###エラーコード
web_1 | django.db.utils.ProgrammingError: relation "journals_journal" does not exist web_1 | LINE 1: ...time", "journals_journal"."updated_datetime" FROM "journals_...
該当のソースコード
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 2from .models import Journal 3 4 5def index(request): 6 journals = Journal.objects.order_by('-created_datetime') 7 return render(request, 'journals/index.html', {'journals': journals}) 8 9
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{% for journal in journals %} 4 {{ journal.title }} 5{% endfor %} 6 7
models.py
models.py
1from django.db import models 2 3 4class Journal(models.Model): 5 title = models.CharField(blank=False, null=False, max_length=150) 6 text = models.TextField(blank=True) 7 created_datetime = models.DateTimeField(auto_now_add=True) 8 updated_datetime = models.DateTimeField(auto_now=True) 9 10 def __str__(self): 11 return self.title 12
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
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2019/04/20 11:08
2019/04/20 11:14
2019/04/20 11:20
2019/04/20 11:22
2019/04/20 11:38
2019/04/20 11:43
2019/04/20 12:12
2019/04/20 12:30
2019/04/21 00:42
2019/04/21 13:17