Here are some frequently used commands when developing with Python/Django.
I would like to take this opportunity to thank you for solving the problem by borrowing the wisdom of our predecessors, and I am very sorry to say that I will summarize it here as my own memo.
(Production environment)
(Development environment)
Python makes it easy to install a wide variety of packaged software over the Internet using the "pip" command. You can check what kind of package software is available on PyPI (The Pyhon Package Index).
Enter the Python virtual environment and do the following:
Terminal
(venv_<Project name>)$pip install django to install the latest version
(venv_<Project name>)$ pip install django==3.1.3 When installing the specified version
You can check the version of the installed package below.
Terminal
(venv_<Project name>)$ python -m django -- version
3.1.3
Terminal
(venv_<Project name>)$ pip install psycopg2-binary
(venv_<Project name>)$ pip install django-allauth
(venv_<Project name>)$ pip install pillow
(venv_<Project name>)$ pip install selenium
(venv_<Project name>)$ pip install boto django-ses
(venv_<Project name>)$ pip install gunicorn
Module name | Explanation |
---|---|
psycopg2-binary | Driver used when connecting to PostgreSQL from Python * 2020/As of 12, psycopg3 is under development |
django-allauth | Authentication feature package that supports local and social authentication |
pillow | Package used when handling static files uploaded through web applications |
selenium | Package used for test method using Live Server Test Case class * SeparatelyDriver for ChromeIs necessary |
django-ses | Amazon SES(Simple Email Service)Packages required to use |
gunicorn | (AbbreviationforGreenUnicorn)Pythonwsgi(WebServerGatewayInterface)HTTP server |
Occasionally, pip itself has been upgraded, so when you execute the pip command, "Upgrade! Please. In such a case, do the following:
Terminal
$ python -m pip install --upgrade pip
Write the modules installed in the Python development environment to a file. Then, based on the exported file, install the module in the production environment.
Terminal
(venv_<Project name>)$ pip freeze > requirements.txt
requirements.txt(Example)
appdirs==1.4.4
astroid==2.4.2
beautifulsoup4==4.9.3
certifi==2020.11.8
chardet==3.0.4
colorama==0.4.4
distlib==0.3.1
filelock==3.0.12
idna==2.10
isort==5.6.4
lazy-object-proxy==1.4.3
mccabe==0.6.1
numpy==1.19.4
pandas==1.1.4
Pillow==8.0.1
pipenv==2020.11.15
pylint==2.6.0
python-dateutil==2.8.1
pytz==2020.4
requests==2.25.0
selenium==3.141.0
six==1.15.0
soupsieve==2.0.1
toml==0.10.2
urllib3==1.26.2
virtualenv==20.1.0
virtualenv-clone==0.5.4
wrapt==1.12.1
Terminal
(venv_<Project name>)$ pip install -r requirements.txt
[Python/Django] Summary of frequently used commands (1) <Creating virtual environment, project, application>
[Python/Django] Summary of frequently used commands (3)
It's surprisingly easy to forget to install django-ses. At the time of testing, one of the reasons is that logs and email contents are output to the console, but when I was just starting to create an application, I often said "django-ses is not enough!" I was angry. When creating a website or web application that uses user authentication or sets up an inquiry form, you should almost always take care of django-ses, so pay attention to the package to be installed. I would like to proceed with development.
Recommended Posts