目次
文書の過去の版を表示しています。
Djangoのインストール
ここでは、Pythonがインストールされていることを前提に説明を進めることにする。
Python 環境の整え方は、pythonbrew の使い方やPython のインストールを参照のこと。
pip を利用する場合
Linux
$ pip install django
Collecting django
Downloading Django-1.9.1-py2.py3-none-any.whl (6.6MB)
100% |████████████████████████████████| 6.6MB 80kB/s
Installing collected packages: django
Successfully installed django-1.9.1
$ python -c "import django; print(django.get_version())"
1.9.1
Windows
> pip install django
Collecting django
Downloading https://files.pythonhosted.org/packages/39/b0/2138c31bf13e17afc32277239da53e9dfcce27bac8cb68cf1c0123f1fdf5/Django-2.2.3-py3-none-any.whl (7.5MB)
|████████████████████████████████| 7.5MB 3.3MB/s
Collecting sqlparse (from django)
Downloading https://files.pythonhosted.org/packages/ef/53/900f7d2a54557c6a37886585a91336520e5539e3ae2423ff1102daf4f3a7/sqlparse-0.3.0-py2.py3-none-any.whl
Requirement already satisfied: pytz in c:\python37\lib\site-packages (from django) (2019.1)
Installing collected packages: sqlparse, django
Successfully installed django-2.2.3 sqlparse-0.3.0
> python -c "import django; print(django.get_version())"
2.2.3
Windows tar ボールからインストールする場合
※pipでインストール可能。
- Django | Download より Django-x.x.x.tar.gz をダウンロードする。
- Django-x.x.tar.gz を適当なフォルダに解凍する。
- コマンドラインにて解凍したフォルダにcd(Change directory)して以下のコマンドを実行する。
> python setup.py install
Linux(Fedora) yum でインストールする場合
※pipでインストール可能。
- djangoパッケージをインストールする。
# yum install django
Django Adminツールの動作確認
上記のインストールが完了すると、django-admin.py がパスの通った場所に存在するので、以下のコマンドを実行して動作確認を行う。
Linux
$ django-admin.py
Type 'django-admin.py help <subcommand>' for help on a specific subcommand.
Available subcommands:
[django]
check
compilemessages
createcachetable
dbshell
diffsettings
dumpdata
flush
inspectdb
loaddata
makemessages
makemigrations
migrate
runserver
~省略~
Windows
> django-admin
Type 'django-admin help <subcommand>' for help on a specific subcommand.
Available subcommands:
[django]
check
compilemessages
createcachetable
dbshell
diffsettings
dumpdata
flush
inspectdb
loaddata
makemessages
makemigrations
migrate
runserver
sendtestemail
shell
showmigrations
sqlflush
sqlmigrate
sqlsequencereset
squashmigrations
startapp
startproject
test
testserver
Note that only Django core commands are listed as settings are not properly configured (error: Requested setting INSTALLED_APPS, but settings are not configured. You must either define the environment variable DJANGO_SETTINGS_MODULE or call settings.configure() before accessing settings.).