django installation

2019-05-07

let's see how to install django and how to configure django.

Outline

I try to develop the serverside by python django. in this blog post, I’ll introduce how to install and configure django for developing.

Installation

we need to install python to use django. click the link below. download and install suitable python on your OS.

I mainly use Mac for developing. also, I use zsh for the terminal. you can see how to set python and zsh on Mac via the links below.

after setting zsh and python via the links above, execute the command below to check python version.

python --version
Python 3.7.2

execute the command below to install virtualenv module that supports to make python Virtual Environment easily.

pip install virtualenv pylint autopep8

execute the command below to make django development environment.

mkdir server
cd server
virtualenv venv

execute the command below to activate Virtual Environment.

source venv/bin/activate

execute the command below to install django in Virtual Environment.

pip install django

after installation, execute the command below to check django installed well.

django-admin --version
# 2.2

execute the command below to save the development environment to a file.

pip freeze > requirements.txt

after checking the installation, execute the command below to quit Virutal Environment.

deactivate

execute the command below again to check Virtual Environment quit well

django-admin --version
# zsh: command not found: django-admin

we can understand what Virtual Environment is via the command above. we’ve installed django in Virtual Environment. so in Virtual Environment quit state, if we execute the django command, we can see the error message that django command not found. which means, we can isolate python development environment by python Virtual Environment.

How To Use On Other Machines

python Virtual Environemt is just an environment. so we don’t need it to be version controlled by git. add the content below to .gitignore file.

# .gitignore
...
venv

and then save requirements.txt on git(commit and push). in other machines, clone it from git and install Virtual Environment by the command. after it, install django by the command below.

pip install -r requirements.txt

we’ll use many modules during developing. after installing the modules, execute the command below to update requirements.txt.

pip freeze > requirements.txt

Completed

we’ve seen how to install python and how to use python Virtual Environment for using django. finally, we’re ready to develop with django. after, I’ll introduce how to develop the serverside with django.

Buy me a coffeeBuy me a coffee
Posts