Django is a great Python based framework for creating outstanding app. You can install and use it on your own computer by creating a virtual environment. Today we will look at how we can install Django & Python and start deploying them right away.
We will Django through command prompt or Terminal from the computer. We will install Django through the following commands line in the terminal.
[php]
cd [the path to your documents eg: /Users/cavan/Documents]
mkdir python_stuff
cd python_stuff
python3 -m venv env
source env/bin/activate
pip install django
django-admin startproject my_project
cd my_project
python3 manage.py runserver
127.0.0.1:8000
[/php]
Explanations:
cd [the path to your documents eg: /Users/cavan/Documents] is the address of your Documents root folder. Here we will keep all our files.
mkdir python_stuff: This command will create a directory in the name of “python_staff”. You can keep change to any name you want.
cd python_stuff: With this command you will go inside the directory you just created with the above command line.
python3 -m venv env: This command will create the folder named “env” inside the project folder. In this folder, the latest Python files will be installed.
source env/bin/activate: This will activate the project and initiate the virtual server for the app deployment.
pip install django: This command line will install Django in env folder.
django-admin startproject my_project: This command will create the main app folder inside the project root. The folder name will be my_project. You can change to any name.
python3 manage.py runserver: This will start/restart the server and the the local URL will be ready to visit and you will see the default DJango install by visiting this URL from your browser: 127.0.0.1:8000.
Note that the above instructions for installing DJango in your local computer is for both Windows and Mac. In the above command lines, if you notice, you will see “python3”, it is for Mac. if you are using Windows, just remove “3”. Then all command will work. Let me know in the comment box if you face any problem installing Django.