[My memo] Preparing Django-Starting

Premise

--python 3.5 is installed --virtualenv must be installed

Preparing the virtual environment

~/


$ mkdir -p ~/app/virtualenv
$ cd ~/app/virtualenv
$ virtualenv -p python3.5 project_name
$ ls -l
total 0
drwxr-xr-x  5 user_name  group_name  170 12 28 22:28 project_name

Use a virtual environment

~/


$ . ~/app/virtualenv/project_name/bin/activate
$ python --version
Python 3.5.0

Django installation

~/


$ pip install django
Collecting django
  Using cached Django-1.9-py2.py3-none-any.whl
Installing collected packages: django
Successfully installed django-1.9

Creating a working directory

~/


$ mkdir -p ~/app/projects/project_name

Creating a project

~/app/projects/project_name


$ cd ~/app/projects/project_name
$ django-admin.py startproject project_name
├── run.sh
└── project_name
    ├── manage.py
    └── project_name
        ├── __init__.py
        ├── settings.py
        ├── urls.py
        └── wsgi.py

Creating a start command

run.create sh


$ vim run.sh

run.sh(Set start command)


python ./project_name/manage.py runserver

Give execute permission


$ chmod +x run.sh

DB

~/app/projects/project_name


$ python ./project_name/manage.py migrate

Creating an initial user

~/app/projects/project_name


$ python ./project_name/manage.py createsuperuser

Start-up

run.sh


$ ./run.sh

Access from browser

http://localhost:8000

--The following screen is displayed スクリーンショット 2015-12-29 0.19.20.png

http://localhost:8000/admin

--The following management screen login is displayed

スクリーンショット 2015-12-29 0.19.09.png

--Screen display after login

スクリーンショット 2015-12-29 0.18.53.png

Recommended Posts

[My memo] Preparing Django-Starting
[My memo] python
My python environment memo
[My memo] python -v / python -V
Python Tips (my memo)
Qiita memo of my thoughts
My reverse numpy / scipy memo