Python Django 入門トップページ


Django によるコメント掲示板の開発:目次

  1. プロジェクトの作成
  2. Git でコミット
  3. Web サーバを起動しておく
  4. Config
  5. Comments アプリケーションを作る
  6. アプリケーションを有効にする
  7. はじめてのビューを作成する
  8. モデルを作る
  9. マイグレーション
  10. テストデータの設定
  11. データベースからコメント一覧を取得して表示してみよう
  12. Bootstrap の導入
  13. コメントの詳細表示
  14. urls.pyの書き方
  15. HTML のテンプレート化
  16. コメントの新規投稿
  17. コメントの編集機能を追加する
  18. さらにテンプレート化
  19. モデル,マイグレーションファイル,フォームの関連
  20. 入力内容の検証(バリデーション)
  21. コメントを削除する
  22. 一覧を逆順にする
  23. ページネーション
  24. フラッシュメッセージ
  25. Static コンテンツの設置
  26. 更新や削除にもフラッシュメッセージを表示
  27. テストの自動化を実現しよう
  28. デバッグツールバーを使う
  29. generic モジュールを使わずにコメント一覧を取得する
  30. コメント一覧のページネーション
  31. 一覧の表示順序を制御する
  32. generic モジュールを使わずにコメントの詳細を表示する
  33. コメント詳細にページ送り機能を作成する
  34. generic モジュールを使わずにコメント登録機能を作成する
  35. generic モジュールを使わずにコメント編集機能を作成する
  36. generic モジュールを使わずにコメント削除機能を作成する

Django によるコメント掲示板の開発

Git でコミット

Git によるバージョン管理を行っているのであれば,ここでコミットしておくと良い.以降の作業でもキリの良い箇所で随時コミットしておくことを推奨する.

(py39) C:\Users\lecture\Documents\django\django_comment>dir ⏎
 ドライブ C のボリューム ラベルがありません。
 ボリューム シリアル番号は E033-4666 です

 C:\Users\lecture\Documents\django\django_comment のディレクトリ

2022/07/27  10:50    <DIR>          .
2022/07/27  10:50    <DIR>          ..
2022/07/27  10:50    <DIR>          django_comment
2022/07/27  10:50               692 manage.py
               1 個のファイル                 692 バイト
               3 個のディレクトリ  14,137,667,584 バイトの空き領域

(py39) C:\Users\lecture\Documents\django\django_comment>git init ⏎
Initialized empty Git repository in C:/Users/lecture/Documents/django/django_comment/.git/

(py39) C:\Users\lecture\Documents\django\django_comment>git add . ⏎

(py39) C:\Users\lecture\Documents\django\django_comment>git status ⏎
On branch master

No commits yet

Changes to be committed:
  (use "git rm --cached <file>..." to unstage)
        new file:   django_comment/__init__.py
        new file:   django_comment/asgi.py
        new file:   django_comment/settings.py
        new file:   django_comment/urls.py
        new file:   django_comment/wsgi.py
        new file:   manage.py


(py39) C:\Users\lecture\Documents\django\django_comment>git commit -m "Initial commit" ⏎
[master (root-commit) 2f1f41e] Initial commit
 6 files changed, 198 insertions(+)
 create mode 100644 django_comment/__init__.py
 create mode 100644 django_comment/asgi.py
 create mode 100644 django_comment/settings.py
 create mode 100644 django_comment/urls.py
 create mode 100644 django_comment/wsgi.py
 create mode 100644 manage.py

(py39) C:\Users\lecture\Documents\django\django_comment>git log ⏎
commit 2f1f41ecf300c06056766fb52b2c9326caeba684 (HEAD -> master)
Author: Gakuin Hanako <gakuin.hanako@dummy.kobegakuin.ac.jp>
Date:   Wed Jul 27 10:54:22 2022 +0900

    Initial commit

(py39) C:\Users\lecture\Documents\django\django_comment>

さらに,今後作成されるデータベースファイルやキャッシュなどのファイルが git に登録されないようにするために,.gitignore というファイルを作成する.ファイルの編集に Visual Studio Code を利用するのであれば,code . で Visual Studio Code を起動し,プロジェクトのフォルダを開くことができるので覚えておくと良い.(なお,Windows 環境では .DS_Store の行は不要です.)

(py39) C:\Users\lecture\Documents\django\django_comment>code . ⏎

(py39) C:\Users\lecture\Documents\django\django_comment>
 .gitignoredb.sqlite3
*/__pycache__/
*/*/__pycache__/
.coverage
htmlcov
.DS_Store

.gitignore を作成したら Git でコミットしておく.

(py39) C:\Users\lecture\Documents\django\django_comment>dir ⏎
 ドライブ C のボリューム ラベルがありません。
 ボリューム シリアル番号は E033-4666 です

 C:\Users\lecture\Documents\django\django_comment のディレクトリ

2022/07/27  10:57    <DIR>          .
2022/07/27  10:57    <DIR>          ..
2022/07/27  10:57                77 .gitignore
2022/07/27  10:50    <DIR>          django_comment
2022/07/27  10:50               692 manage.py
               2 個のファイル                 769 バイト
               3 個のディレクトリ  14,137,307,136 バイトの空き領域

(py39) C:\Users\lecture\Documents\django\django_comment>git status ⏎
On branch master
Untracked files:
  (use "git add <file>..." to include in what will be committed)
        .gitignore

nothing added to commit but untracked files present (use "git add" to track)

(py39) C:\Users\lecture\Documents\django\django_comment>git add . ⏎

(py39) C:\Users\lecture\Documents\django\django_comment>git commit -m"gitignore" ⏎
[master 2b7a426] gitignore
 1 file changed, 6 insertions(+)
 create mode 100644 .gitignore

(py39) C:\Users\lecture\Documents\django\django_comment>

目次に戻る