I wrote like below at previous post(DjangoNote Outline)

We will prepare CentOS7 as virtual machine on local PC and develop with the setting for production env(DEBUG = False). When we know how to see error and to display static files, there is no need for us to operate with DEBUG = True.

But first, can't help to start from here.


Python3.6 virtual env on local PC

Not polluting the existing env on Mac, let's prepare Python3.6 used only for this project.

Install pyenv, pyenv-virtualenv

Run commands below in terminal.

# Install pyenv.
$ brew install pyenv

# Install pyenv-virtualenv
$ git clone https://github.com/yyuu/pyenv-virtualenv.git ~/.pyenv/plugins/pyenv-virtualenv

Create ~/.bash_profile and add below.

export PYENV_ROOT=$HOME/.pyenv
eval "$(pyenv init -)"
eval "$(pyenv virtualenv-init -)"

Back into terminal, run these commands to check.

# Apply bash_profile.
$ source ~/.bash_profile

# If pyenv exists.
$ which pyenv

# If pyenv-virtualenv exists.
$ which pyenv-virtualenv

Create Python3.6 env with pyenv, pyenv-virtualenv

# Install 3.6.3 to create a virtual env named djangoenv3.6.3
$ pyenv install 3.6.3
$ pyenv virtualenv 3.6.3 djangoenv3.6.3

# No need to care about folder name.
$ mkdir aaaa
$ cd aaaa

# This folder gets to be the virtual env of 3.6.3. .python-version file will be created.
$ pyenv local djangoenv3.6.3

# Check.
$ python -V
Python 3.6.3

Upgrade pip.

$ pip install --upgrade pip setuptools
$ pip list
Package    Version
---------- -------
pip        19.1.1 
setuptools 41.0.1


Create Django base

# Create requirements for pip.
$ cat << __EOF__ > requirements.txt

# pip install.
$ pip install -r requirements.txt

# Check.
$ pip list
Package    Version
---------- -------
Django     2.1.8  
pip        19.1.1 
pytz       2019.1 
setuptools 41.0.1

# Create Django project.
$ django-admin startproject config .
$ python manage.py startapp app

# Create sqlite DB actual file.
$ python manage.py migrate



By now, you should open the project.

$ python manage.py runserver

Access to localhost:8000.

Django initial status


Next DjangoNote

Next, we will divide Django setting file in one for test and one for production, DEBUG=True and DEBUG=False in other words.

# Nice Job git commit。

$ git init
$ git commit --allow-empty -m 'Initial Commit.'

# gitignore for Django
$ curl https://raw.githubusercontent.com/jpadilla/django-project-template/master/.gitignore -o .gitignore

$ git add --all
$ git commit -m "Open with runserver"


Now folder looks like this

Now folder looks like this