0
1

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 5 years have passed since last update.

Djangoメモ 環境構築編

0
Posted at

前提条件

・python 3.x のインストール
 -コマンドプロンプトから「python --version」で確認できる

環境構築

・環境をインストール
pip install virtualenvwrapper-win

・プロジェクト用の仮想環境を作成

workon myproject

Djangoのインストール

pip install django
 ⇒これで最新versionがインストールできる

※Djangoが古い場合は削除

python -c "import django; print(django.__path__)"

プロジェクトの作成

コマンドプロンプトでコードを置きたい場所(ドキュメントなど)を指定し、以下を実行。
django-admin startproject mysite
※「mysite」部分は任意のプロジェクト名に変更する

start projectで作成されたファイルの概要

mysite:プロジェクトの名前。好きに変更できる。
manage.py:コマンドラインユーティリティ
mysite/init.py:pythonパッケージであることを知らせる空のファイル
mysite/setting.py:設定ファイル
mysite/urls.py:目次、URLを宣言する場所
mysite/wsgi.py:WSGI(Web Server Gateway Interface)。WEBブラウザに表示させるために必要。

開発用サーバーの起動

python manage.py runserver
manage.pyがあるmysiteディレクトリ内で上記コマンドを実行すると開発サーバーが起動する。
http://127.0.0.1:8000/
にアクセスすることができればOK。
Ctrl+cでサーバーを閉じることができる。

参考にしたページ

はじめての Django アプリ作成、その 1
Windows での Django のインストール方法

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?