LoginSignup
1
4

More than 5 years have passed since last update.

djangoプロジェクト開発環境構築

Posted at

前提

Pythonインストール済み

環境構築

任意のディレクトリでコマンド実行

$ pip install virtualenv
$ virtualenv 任意名

任意名のディレクトリが出来ていたら成功

virtualenvの起動

$ source 任意名パス/任意名ファイル/bin/activate
(任意名) $

※virtualenvを抜けたい時

$ deactivate

djangoインストール

$ pip install django

バージョンを指定したい場合(数字部分を任意)

$ pip install django==1.9.5

djangoがインストールされているか確認するため、
現在インストールされているパッケージを表示

$ pip freeze
appdirs==1.4.0
Django==1.10.5
packaging==16.8
pyparsing==2.1.10
six==1.10.0

djangoプロジェクト作成

virtualenvのディレクトリとは別にプロジェクト用のディレクトリ作成

$ django-admin startproject プロジェクト名

プロジェクト名ディレクトリに移動後、サーバ起動

$ python manage.py runserver
Performing system checks...

System check identified no issues (0 silenced).

You have 13 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.

February 02, 2017 - 08:53:44
Django version 1.10.5, using settings 'fiverr.settings'
Starting development server at http://127.0.0.1:8000/
Quit the server with CONTROL-C.

DBがまだ無いため、1部赤文字になっている箇所があります。
サーバ起動には問題ないため、以下のURLをクリックしてみてください。
http://127.0.0.1:8000/もしくはhttp://localhost:8000

もし、8000番ポートが使われていてエラーが出る場合には、ポート番号を指定してサーバを起動してください

$ python manage.py runserver 8080

以下の画面が出ればdjangoプロジェクトの作成の完了です

9f1a4e9273cba4b698572cb4aa998656.png

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