LoginSignup
0
0

More than 1 year has passed since last update.

動かして学ぶ!Python Django開発入門 第2版 メモ

Last updated at Posted at 2023-01-10

注意

pycharm
references>プロジェクト>Pyhtonインタープリター
でDjangoを入れる

pythonのバージョンが違う場合
psycopg2あたりでバグる
解決策: venvを入れ直す

リスト7.3
タイポ
stylesheetじゃなくてstylsheet
jsdelivrじゃなくてjsdellivr

1つのファイルを作るたびにrunserverしてもエラーになることがよくある
例: 48%のビューを追加
次節で作成するフォームを書いてからじゃないとエラー

リスト8.4
INQUIRYのところを1箇所変えるだけ
図が長いからたくさん修正があると思うけど

リスト10.8
verification_sent.html
図10.7で作るファイルにない

リスト11.27
diary: diary_detail
スペースなくさないとバグる
diary:diary_detail

ssh ec2_ec2-user
途中から
ssh ec2_app_admin

HTTPS化でnginx.confいじったらバグった
戻せないからインストールし直し
sudo yum remove nginx

86%
pip install -r requirements.txt
でエラー
先にpsqlをインストール

90%
SES HomeにDomains>Email Addressesがない
検証済みIDで作成

90%
図12.29のSES制限の解除申請ではねられた
新たに

情報を追加します.

メールを送信する頻度: 1日100件
ウェブサイトやアプリの管理方法: https://github.com/XXX/private_diary 
ウェブサイトの URL: https://private-diary.XXX.com 
EC2, nginx, gunicornを起動しているときにアクセスできます.

と返信すると採用された

94%
空白がわかりやすいよう

リスト12.10
0 4 * * * source~/venv_private_diary/bin/activate;cd~/venv_private_diary/private_diary;pythonmanage.pybackup_diary>~/cron.log2>&1

nginx.conf
バグったらリスト12.9に戻す
独自ドメインではなくElastic IPでなら動く

97%
リスト13.2
return 301 https://$host$request_uri;
でurlにしないように

誤植

58%
password_rest_from_key.html

リスト10.7
kindleでインデントがおかしい

リスト10.9
再申請</a>.</p>
の . いる?

リスト12.7
''が必要なところがある

本番環境 実行方法

何回も実行するのでメモ

  1. awsでインスタンスを実行中にする
  2. nginxを起動する
    まずはSSH接続する
cd .ssh
ssh ec2_app_admin

sudo systemctl start nginx.service
確認する
systemctl status nginx.service

  1. gunicornを起動する
    まずはPython仮想環境に入る
source ~/venv_private_diary/bin/activate
cd ~/venv_private_diary/private_diary

gunicorn --bind 127.0.0.1:8000 private_diary.wsgi -D
確認する
ps ax | grep gunicorn

本番環境 終了方法

  1. gunicornを停止する
    pkill gunicorn
  2. nginxを停止する
    sudo systemctl stop nginx.service
    (1. 2. はexitするだけでいいのだろうか)
  3. awsでインスタンスを停止中にする

未完了のこと

Inquiryがどこにとぶのか

Log inのメールが送られない.

python manage.py collectstatic
requests.txtを読めないせい
代わりに自分でdjango-allauth, django-bootstrap5, Pillowをインストールした
python manage.py makemigrations
で怒られた

参考

AWSで独自ドメインの取得
https://dev.classmethod.jp/articles/relaxing-send-limit-and-removing-sandbox-restriction-in-ses/

ドメイン名をEC2インスタンスに接続
検索「aws ec2 ドメイン 接続」
https://aws.amazon.com/jp/getting-started/hands-on/get-a-domain/

Sourcetreeでコミットできなくなったら
https://otani-rest.site/sourcetree-github/
差分の反映は11章のメモ参照

github
https://github.com/j4pngthr/private_diary

0
0
0

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
0
0