This Post Will Be Part of Hashnode's Writeathon and also part of My Django Related Posts.
So there are many ways to write Back-end for an Web App or Website but we can also write an Web App with Python 3 Programming Language and Django Is One of them.
It's an Free and Open-source Project Created by Django Project Foundation.
For Running an Django Project We Will Need Some Prerequisites like In Our Operating System We Need Python 3.8 or Above Installed.
Mostly the venv module of python is already installed but it's not installed in Most Cases.
So We Can Install the venv module by our system package-manager.
Like Below is for Ubuntu
sudo apt-get install python-venv
And For Windows it Is installed with Python Exe.
The given below code will create an virtual environment in new directory named
# if only python3 is on system python -m venv venv # if multiple python versions are installed on system python3 -m venv venv
Given Below is an Chart about how to activate an virtual environment in that Operating System.
|Platform||Shell||Command to activate virtual environment|
You Can Simply install Django In your vitual environment by running below any pip command.
python3 -m pip install Django # or just python python -m venv pip install Django # Directly pip or pip3 pip install Django pip3 install Django
It will also install automatically an package named
django-admin in our virtualenv.
Open Your Command Shell with virtual environment and Run Below Command.
django-admin startproject django_project
This Will Create an Folder Structure Below.
Whenever you create an django project be aware it rejects the project name with
- hyphen symbols so use
django-admin startproject django_project .
We add an extra argument of path where to create project, here
. dot symbol is used for current directory of relative path.
It will create an different folder structure like given below.
Now we can run our django project directly with given below command, but be aware this command are for development environment only.
python manage.py runserver
Given Below is an image of the Django Project Running.
If you found this useful then please share this and follow me! Also check out Buy Me A Coffee if you want to support me on a new level!
Thanks for reading untill now.