1
3

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.

PythonのDjangoのプロジェクト作成までを瞬時に終わらせる

Last updated at Posted at 2019-01-28

Djangoは触ったことがある、けどプロジェクトを作成する手順は毎回忘れる!面倒くさい!という時のための備忘録です。

始めに

まずは以下のコマンドを打ち込みます。

> cd HelloWorld
> python -m venv env
> env\Scripts\activate
> python -m pip install --upgrade pip
> echo Django~=2.0.6 > requirements.txt
> pip install -r requirements.txt
> django-admin.exe startproject HelloWorld .
> vim HelloWorld/settings.py
HelloWorld/HelloWorld/settings.py
LANGUAGE_CODE = 'ja'
TIME_ZONE = 'Asia/Tokyo'

STATIC_URL = '/static/'
STATIC_ROOT = os.path.join(BASE_DIR, 'static') # 静的ファイルのパス
> python manage.py migrate
> python manage.py runserver

出来ました。

image.png

ちなみに

macでは
以下のコマンドでは権限がないと怒られましたが

$ ./env/bin/activate
-bash: ./env/bin/activate: Permission denied

以下のコマンドでは入れました。

$ source env/bin/activate
(env) KnothMBP:DjangoHW knoth$ 

requirements.txtの作成については
他の方法として、以下のように書き出すこともできます。
こっちの方が使い勝手は良さそうですね。

pip install Django
pip install django-bootstrap4
pip freeze > requirements.txt

以上です。

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?