There is a programming setback: building an environment is 7,000 times more difficult than you might think. I spent a lot of effort building the environment ... At that time, I was rushing in the style of moving my hands even if I didn't understand it, but recently I've finally caught up with my understanding, so I'd like to summarize it here. Don't think too hard, simply step by step to build your Django development environment.
――The author is Windows, so please read as appropriate for Mac users. --If you have already installed Python, skip the relevant section.
Access the URL below. https://www.python.org/
Select Latest: Python 3.8.3 for Download.
You've arrived at the Python 3.8.3 page. If you scroll to the bottom, you can see Files.
As you can see, you can download the source code for each Mac OS and Windows. This time, download the Windows x86-64 executable installer (for Windows 64bit). For Windows 32bit, select Windows x86 executable installer. Which is your Windows? You can check this by following the steps at here.
After the download is complete, launch the installer.
Check Add Python 3.8 to PATH to start the installation.
Installation is complete!
When developing with Python, it is often the case that the required modules and packages differ depending on the application. It's possible to put them all in one place, but that would be very cumbersome to manage. Also, if different module versions are mixed, it seems that problems due to different versions will occur. ** Virtual environment ** solves these problems. Have different virtual environments for different applications, such as Django 2.2 for web application A development and Django 3.0 for web application B development. Below are references.
From here, we will actually build a virtual environment. Go to any directory and then install virtualenv
, which is needed to build the virtual environment.
C:\Users\User_name\my_django>pip install virtualenv
Collecting virtualenv
~
Successfully installed appdirs-1.4.4 distlib-0.3.0 virtualenv-20.0.21
Then execute the following command. This time we will create a virtual environment called myvenv
.
C:\Users\User_name\my_django>virtualenv myvenv
Then do the following:
C:\Users\User_name\my_django>myvenv\Scripts\activate
Then, (myvenv)
may be displayed on the left side of C. The virtual environment is now started. By the way, to disable it, execute the following command.
(myvenv)C:\Users\User_name\my_django>deactivate
Install Django right away. After confirming that you are in the virtual environment, execute the following command.
(myvenv)C:\Users\User_name\my_django>pip install django
Collecting django
~
Successfully installed asgiref-3.2.7 django-3.0.6 sqlparse-0.3.1
Once Django is installed, you're done!
(myvenv) C:\Users\User_name\my_django>pip list
Package Version
---------- -------
asgiref 3.2.7
Django 3.0.6 <-Django! pip 20.1.1 pytz 2020.1 setuptools 46.4.0 sqlparse 0.3.1 wheel 0.34.2
Let's get in touch with Django as soon as the development environment is ready! If you are new to this, you can complete the tutorial by following the Official Documents and Django Girls Tutorial, or I wrote for myself in the past [Tutorial](https://qiita.com/Yi- You can also see Gaoqiao / items / c5b41d22907016ae1d0f) (Qiita maiden work)! (It also touches on how Django works, so if you don't mind!)
-Django Official Documentation
Recommended Posts