[PYTHON] django environment construction


Python is installed and commands can be used.

Virtual environment

The installation state of the package is independent for each project from the virtual environment. Virtual environment with venv. 1. </ b> First, create a folder. 2. </ b> Then use Terminal or Command Prompt. 3. </ b> Enter the created folder.

Create virtual environment Depending on the environment, you may not need 3! ⬇︎

python3 -m venv [newenvname]

Enter the virtual environment. linux,Mac

source [newenvname]/bin/activate





Package installation

([newenvname])$ pip install [package name]

Exit the virtual environment

([newenvname])$ deactivate

django build

Install django in a virtual environment

pip install django

django project creation
It will be the basis.

django-admin startproject [project name]

Please enter the project.

cd [project name]

Start django server Please check if you could create it below.

python manage.py runserver

In django there is the concept of an application Separate functions for each application. Creating an application.

python manage.py startapp [app name]


Change port number Change 8080 to any number.

python manage.py runserver 8080

I also have a Hatena blog, so please take a look.

This is the URL ⬇︎ https://taitoajiki.hatenablog.com/archive/category/Django

Recommended Posts