1
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

Django Docker-compose メモ

Last updated at Posted at 2021-12-29

#作成するファイル(3つ)
Dockerfile
requirements.txt
docker-compose.yml

Djangoプロジェクト作成(上記同一フォルダにて下記コマンド実行)

#Django project app 作成

Djangoプロジェクト作成(上記同一フォルダにて下記コマンド実行)

docker-compose run --rm web django-admin.py startproject mysite .

Djangoアプリ作成(上記同一フォルダにて下記コマンド実行)

docker-compose run --rm web django-admin startapp myapp;

#実行コマンド

docker-compose up

複数Dockerコンテナを起動(動作確認)
setting.py
ALLOWED_HOSTS = []を
ALLOWED_HOSTS = ["*"]に変更(Dockerを動かしているホストの名前、IPアドレス)

settings.py
INSTALLED_APPS = [
    ......,
    myapp, #アプリ名
]
project/urls.py
urlpatterns = [
    ......,
    path('myapp/', include('myapp.urls')),
]
app/urls.py
urlpatterns = [
    ......,
    path('', TopView.as_view(), name='home'),
]

->view.py->templates/myapp/home.html

#form.py

from django import forms

class SendUrlForm(forms.Form):
    url_contents = forms.CharField(
        label='SendUrl',
        widget=forms.Textarea(attrs={'cols': '80', 'rows': '1'})
        )
views.py

self.params = {
            ......,
            'form_send_url':SendUrlForm(),
        }

herokuデプロイ用データベース設定

settings.py

DATABASES = {
                ・・・・・・
        'ENGINE': 'django.db.backends.postgresql_psycopg2',
                ・・・・・・
    }
}

herokuchromedriver使用メモ

requirements.txt
Chromedriver-binary
1
2
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?