Have you ever created Web Applications?
Don't worry if not I will teach you how to create the web application using Django.
What is Django?
Python-based web framework Django allows you to create efficient web applications quickly. It is also called batteries included web framework Django because It provides built-in features for everything including Django Admin Interface, default database – SQLlite3, etc.
Lets Learn Practically!!
Before get into create the folder then open the folder in vscode or in your favourite browser.
Virtual Environment
A virtual environment is a tool that helps to keep dependencies required by different projects separate by creating isolated Python virtual environments for them. This is one of the most important tools that most Python developers use.
How to Create Virtual Environment
To create Virtual Environment Run following command in your terminal
python -m venv .venv
it will create the folder venv
Run the virtual Environment
To run the virtual environment run following command
.venv\Scripts\activate
Install the Necessary Libraries
we need the Django library to create the Django App so install the Django libraries by run the following command
pip install django
Create the Project
Django needs a project within the project our necessary codes are there
and it need Apps
To create project run following command
django-admin startproject example .
Here, the example is the name of the project and represents creating a project within the folder if we didn't mention it. it creates a subfolder with the same project name.
After Running the command it creates some of the files for our django project.
Create App
A project has many app for many features of the web applications For example if we web Application in our app has login for that we create separate app.
To Create App Run following command
django-admin startapp home
it create folder name Home within the folder it has few files which is the necessary file to run our App
Add our App Name in the Setting.py
Setting.py is main file required to run our webapp in that file contains configurations of our app.
now we add our app in the settings.py file.
Run Our WebApp
All set we can run our app using the development server django has the inbuilt developement server.
To start Developement server Run the Following command
python manage.py runserver
Yayy!!!!
Now we can see our app on http://127.0.0.1:8000/
If you got above output you successfully Run the Django App.
Linkedin-Connect with me
Comment "Django" for the next part
Top comments (0)