By Guru - January 17, 2023
Getting started with Django
Setup and create first Project
Django is high-level web framework of python programming language. Django is free and open source framework used to create fast server-side backend applications.
Note : In this article we use Python>=3.8 (Python 3.10 is recommended) and Django>=4.0 (Django 4.0 is recommended)
I Assume you have :
Basic knowledge of Python programming language.
Basic knowledge of Web Technology i.e HTML, CSS and Javascript.
Check if Python is installed in your system
Open terminal and run below command
>> python3 --version
If Python is not installed refer to this Install Python
Creating environment
Django installation is quite simple. We can use pip command to install django in the system.
It is recommended to use virtual environment for dependencies and other packages.
Create a virtual environment
>> Python3 -m venv env
Activate virtual environment
>> source env/bin/activate
Installing Django
Install python using pip command
>> pip3 install django
This command install latest version of django in your system
Creating your first Project
Creating a django project is very simple you just need to run a command below in desired direcrory.
>> django-admin startproject myproject
Above command create you project and file structure with required files.
----- img -----
Lets analyse files and directory created by above command.
There is a directory with name myproject which is root of the project and contains a file manage.py and a directory with same name as myproject which have all project related files.
manage.py : This is the entry point when we run our application.
settings.py : This file contains all the configurations, project settings.
wsgi.py : This is web server gateway interface used to communicate between application and and server.
asgi.py : This is asynchronous form of wsgi.
urls.py : This file have routes definitions of the project
__init__.py : This file lets the Python interpreter know that a directory contains code for a Python module.
0 Comments