1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

【初心者向け】Djangoでローカルサーバーを立ち上げるまで

Last updated at Posted at 2024-12-15

Djangoを勉強するにあたって記録をつけています。
他の方の参考になれば幸いです。

開発環境
 Visual Studio Code

1. Djangoをインストールする

ターミナルを開き、Djangoをインストールします。

pip install django

インストールの成功を確認してください。

image.png

2. Djangoのプロジェクトを作成する

ターミナルを開き、プロジェクトを作成したい任意のディレクトリに移動します。

image.png

コマンドを打ち込み、プロジェクトを作成します。(yourprojectは任意のプロジェクト名)

django-admin startproject yourproject

画像のようにフォルダ、ファイルが作成されていることを確認してください。

image.png

3. Djangoアプリケーションを作成する

terminalに下のコマンドを打ち込み、作成したプロジェクトに移動します。

cd yourproject

4. プロジェクトが作成できたことを確認する

terminalに以下のコマンドを打ち込み、ローカルサーバーを立ち上げます。

python 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.
December 15, 2024 - 18:07:18
Django version 5.1.4, using settings 'yourproject.settings'
Starting development server at http://127.0.0.1:8000/
Quit the server with CTRL-BREAK.

[15/Dec/2024 18:07:30] "GET / HTTP/1.1" 200 12068

http://127.0.0.1:8000/にカーソルを合わせると画像のように表示されるので、指示に従いキーボードのcontrolキーを押しながら、クリックします。

image.png

プロジェクトの作成が成功していれば、下のようなロケットの画像が表示されます。

image.png


次の作業

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?