文書の表示以前のリビジョンバックリンク文書の先頭へ この文書は読取専用です。文書のソースを閲覧することは可能ですが、変更はできません。もし変更したい場合は管理者に連絡してください。 ====== Django のインストール ====== ここでは、Python がインストールされていることを前提に説明を進めることにする。\\ Python 環境の整え方は、[[python:pythonbrew|pythonbrew の使い方]]や[[python:python_install|Python のインストール]]を参照のこと。\\ ===== pip を利用する場合 ===== ==== Linux ==== <code> $ pip install django </code> <WRAP prewrap 100% #result> <code> Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple Collecting django Downloading https://files.pythonhosted.org/packages/08/c7/7ce40e5a5cb47ede081b9fa8a3dd93d101c884882ae34927967b0792f5fb/Django-3.1.4-py3-none-any.whl (7.8MB) 100% |████████████████████████████████| 7.8MB 4.2kB/s Collecting asgiref<4,>=3.2.10 (from django) Downloading https://files.pythonhosted.org/packages/89/49/5531992efc62f9c6d08a7199dc31176c8c60f7b2548c6ef245f96f29d0d9/asgiref-3.3.1-py3-none-any.whl Collecting sqlparse>=0.2.2 (from django) Downloading https://files.pythonhosted.org/packages/14/05/6e8eb62ca685b10e34051a80d7ea94b7137369d8c0be5c3b9d9b6e3f5dae/sqlparse-0.4.1-py3-none-any.whl (42kB) 100% |████████████████████████████████| 51kB 155kB/s Collecting pytz (from django) Downloading https://files.pythonhosted.org/packages/12/f8/ff09af6ff61a3efaad5f61ba5facdf17e7722c4393f7d8a66674d2dbd29f/pytz-2020.4-py2.py3-none-any.whl (509kB) 100% |████████████████████████████████| 512kB 52kB/s Installing collected packages: asgiref, sqlparse, pytz, django Successfully installed asgiref-3.3.1 django-3.1.4 pytz-2020.4 sqlparse-0.4.1 </code> </WRAP> <code> $ python -m django --version" </code> <WRAP prewrap 100% #result> <code> 3.1.4 </code> </WRAP> ==== Windows ==== <code> > pip install django </code> <WRAP prewrap 100% #result> <code> Collecting django Downloading Django-3.0.4-py3-none-any.whl (7.5 MB) |████████████████████████████████| 7.5 MB 1.1 MB/s Collecting sqlparse>=0.2.2 Downloading sqlparse-0.3.1-py2.py3-none-any.whl (40 kB) |████████████████████████████████| 40 kB 2.5 MB/s Collecting asgiref~=3.2 Downloading asgiref-3.2.7-py2.py3-none-any.whl (19 kB) Collecting pytz Downloading pytz-2019.3-py2.py3-none-any.whl (509 kB) |████████████████████████████████| 509 kB 1.7 MB/s Installing collected packages: sqlparse, asgiref, pytz, django Successfully installed asgiref-3.2.7 django-3.0.4 pytz-2019.3 sqlparse-0.3.1 </code> </WRAP> <code> > python -c "import django; print(django.get_version())" </code> <WRAP prewrap 100% #result> <code> 3.0.4 </code> </WRAP> ===== Windows tar ボールからインストールする場合 ===== ※pipでインストール可能。 - [[http://www.djangoproject.com/download/|Django | Download]] より Django-x.x.x.tar.gz をダウンロードする。 - Django-x.x.tar.gz を適当なフォルダに解凍する。 - コマンドラインにて解凍したフォルダにcd(Change directory)して以下のコマンドを実行する。<code> > python setup.py install </code> ===== Linux(Fedora) yum でインストールする場合 ===== ※pipでインストール可能。 - djangoパッケージをインストールする。<code> # yum install django </code> ====== Django Adminツールの動作確認 ====== 上記のインストールが完了すると、django-admin.py がパスの通った場所に存在するので、以下のコマンドを実行して動作確認を行う。\\ ===== Linux ===== <code> $ django-admin.py </code> <WRAP prewrap 100% #result_long> <code> 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 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.). </code> </WRAP> ===== Windows ===== <code> > django-admin </code> <WRAP prewrap 100% #result_long> <code> 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.). </code> </WRAP> ====== 参考文献 ====== [[http://www.ibm.com/developerworks/jp/linux/library/l-django/index.html|Python Webフレームワーク、第1回: DjangoとPythonを使ってWeb開発]]\\ python/django/django_install.txt 最終更新: 2020/12/11 17:34by ともやん