Django is a Python-based web framework that allows you to quickly create web applications without all of the installation or dependency problems that you normally will find with other frameworks. When you’re building a website, you always need a similar set of components: a way to handle user authentication (signing up, signing in, signing out), a management panel for your website, forms, a way to upload files, etc.
Python Django
Django is used in many popular sites like Disqus, Instagram, Knight Foundation, MacArthur Foundation, Mozilla, National Geographic, etc. There are more than 5k online sites based on the Django framework. ( Source ) Sites like Hot Frameworks assess the popularity of a framework by counting the number of GitHub projects and StackOverflow questions for each platform, here Django is in 6th position. Web frameworks often refer to themselves as “opinionated” or “un-opinionated” based on opinions about the right way to handle any particular task. Django is somewhat opinionated, hence delivering the in both worlds( opinionated & un-opinionated ).
Django gives you ready-made components to use such as:
- It’s very easy to switch databases in the Django framework.
- It has a built-in admin interface which makes it easy to work with it.
- Django is a fully functional framework that requires nothing else.
- It has thousands of additional packages available.
- It is very scalable.
Features of Django
- The versatility of Django: Django can build almost any type of website. It can also work with any client-side framework and can deliver content in any format such as HTML, JSON, XML, etc. Some sites which can be built using Django are wikis, social networks, new sites etc.
- Security: Since the Django framework is made for making web development easy, it has been engineered in such a way that it automatically do the right things to protect the website. For example, In the Django framework instead of putting a password in cookies, the hashed password is stored in it so that it can’t be fetched easily by hackers.
- Scalability: Django web nodes have no stored state, they scale horizontally – just fire up more of them when you need them. Being able to do this is the essence of good scalability. Instagram and Disqus are two Django based products that have millions of active users, this is taken as an example of the scalability of Django.
- Portability: All the codes of the Django framework are written in Python, which runs on many platforms. Which leads to run Django too in many platforms such as Linux, Windows and Mac OS.
Installation and Setup of Django
Install python3 if not installed in your system ( according to configuration of your system and OS) from here . Try to download the latest version of python it’s python 3.11.0 this time.
Note: Installation of Django in Linux and Mac is similar, here I am showing it in windows for Linux and mac just open terminal in place of command prompt and go through the following commands.
Install pip: Open command prompt and enter following command-
python -m pip install -U pip

Set Virtual environment: Setting up the virtual environment will allow you to edit the dependency which generally your system wouldn’t allow. Follow these steps to set up a virtual environment-
Create virtual environment in django: We should first go the directory where we want to create the virtual environment then we type the following command to create virtual environment in django.
python -m venv env_site
then we need to activate virtual environment in django
Activate the virtual environment: Run the activation script located in the bin
directory within the virtual environment folder
env_site\Scripts\activate.bat
source env_site/bin/activate
Install Django: Install django by giving following command
pip install django

Start a project by following command-
django-admin startproject geeks_site

Change directory to geeks_site
cd geeks_site

Start the server- Start the server by typing following command in cmd-
python manage.py runserver

To check whether server is running or not go to web browser and enter http://127.0.0.1:8000/ as URL.

Benefits and Drawbacks of Django Architecture
MVT Architecture
|
Complexity
|
DRY Principle
|
Tight Coupling
|
ORM (Object-Relational Mapping)
|
Boilerplate Code
|
Admin Interface
|
Learning Curve
|
URL Routing and View Handling
|
Duplication of Logic
|
Template System
|
Not Always Suitable for Small Projects
|
Security Features
|
Possible Performance Impact
|
Scalability
|
Lack of Strict Guidelines
|
Modularity and Reusability
|
Testing Complexity
|
Community and Ecosystem
|
Rigidity
|
Versatility
|
Controller Bloat
|
Whether you're preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape,
GeeksforGeeks Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we've already empowered, and we're here to do the same for you. Don't miss out -
check it out now!
Last Updated :
21 Aug, 2023
Like Article
Save Article