Django installation

2021-03-19 hit count image

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.

this blog is a series. if you want to check other blog posts of the series, see the links below.

also, this blog series source code is opened on Github. you can see full source code via the link below.

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.

# cd server
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.

# cd server
pip install -r requirements.txt

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

# cd server
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.

Was my blog helpful? Please leave a comment at the bottom. it will be a great help to me!

App promotion

You can use the applications that are created by this blog writer Deku.
Deku created the applications with Flutter.

If you have interested, please try to download them for free.

Posts