LoginSignup
0
0

More than 3 years have passed since last update.

Djangoを使ったWEBアプリケーションの開発【Django起動編】

Last updated at Posted at 2020-09-17

前提・環境

MacbookPro2017 13inch macOS Catalina 10.15.6
Python 3.6
Djanngo version 3.1.1 ←インストール手順書き忘れてました。そのうち書くかも。

プロジェクトの作成とファイル構成の確認

今回は、djangoフォルダを作成し、その中にプロジェクトを作成していく。
コマンドプロンプトで下記を入力する。

$ mkdir django
$ cd django

「django」フォルダに移動したら、下記を入力するとプロジェクトが作成される。
今回プロジェクト名は「project1」とした。

$ django-admin startproject project1

実行後、作成されたproject1フォルダ内に移動し、ファイルを確認する。

$ cd project1
$ ls
manage.py   project1

さらに、project1フォルダ内のproject1フォルダに移動し、ファイルを確認する。

$ cd project1
$ ls
__init__.py     asgi.py     settings.py urls.py     wsgi.py

以上のファイルが作成されていることを確認したら、一つ上のフォルダに戻ってDjangoサーバーの起動し動作を確認する。

$ cd ..
$ python3.6 manage.py runserver

Watching for file changes with StatReloader
Performing system checks...

System check identified no issues (0 silenced).

You have 18 unapplied migration(s). Your project may not work properly until you apply the migrations for app(s): admin, auth, contenttypes, sessions.
Run 'python manage.py migrate' to apply them.
September 13, 2020 - 07:31:30
Django version 3.1.1, using settings 'project1.settings'
Starting development server at http://127.0.0.1:8000/
Quit the server with CONTROL-C.

サーバーが起動できたらブラウザに「http://127.0.0.1:8000/」を入力する。
ロケットの画像と「The install worked successfully! Congratulations!」の文字が表示されていれば成功です。
screencapture-127-0-0-1-8000-2020-09-13-17_02_45.png

動作が確認できたら、コマンドプロンプトでControl + Cでサーバーを停止させることができます。

初期設定編

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