alt text

You must have heard about web development, and different new technology to build web apps. Different frameworks on different programming language are built to ease the task of web development. New framework are introduce in market in rapid way. But what exactly are the “frameworks”.

What is framework?

Framework is the group of programs and modules built with the aim of providing the base for web development. The main idea is rapid development of secure and maintainable website. Some of the frameworks of web development are Laravel, ASP.NET, Django, etc.

Django is Python web framework and one of the most popular web framework. It is free and open source, has active community, very well written documentation and many more supports.

Other than Django, Python offers two more framework for web development, Flask and FastAPI.

Flask is better for small scale web apps, as it has less modules provided at start.

FastAPI as name suggest is very handy pick for the development of API.

But what makes Django better and very renown in the web development industry.
  • It is terribly fast in development.
  • It is fully loaded with essential components
  • It is reassuringly secure, avoids common security mistakes.
  • It is well scalable and meet heavy traffic demands.

A great web framework abstracts away all the low-level stuff so that you can focus on the core functionality of your application.

The Architecture

Django has MVC architecture, Model View Controller. It basically means that the Model defines the class or to be precise a table. For example: If you create a model for the Students with the fields : name, roll, address. A table name student with the attributes are created.

Similarly the view architecture defines the view logic which necessarily means, how is the view of the web app is determined. What is the response? It also describe about the template portion, the html files.

And finally the controller introduce the url section. It is basically defining what page to load when certain url is requested. It controls these stuffs.

Sometime MVC in django is also called MVT(model, template and view)

Being a framework, it also has other built in features such as:

User authentication and permissions, it is already available in django. There is pre built User model, where the new user can be easily added by creating the data in User table. And to verify set of credentials, authenticate function can be used, which require username and password(by default)

Administration site (default admin site), it has basic function necessary for admin login and access.

Object Relational Mapper(ORM), it basically enables interaction with database with queryset without the need of SQL. ORM is data abstraction API which is easier faster and secure. For example: To get the all students data

Students.objects.all()

Also there are features of Forms, CSRF.

How to setup django?

You can install django by following command (python should be installed if not before this command) :

pip install django

After that to create a django project :

django-admin startproject your_project_name

After the above command a folder with modules like settings.py, wsgi.py and other is created and also apart from folder files a seperate file is created with name “manage.py”.

First of all, manage.py is the command line entity which helps us to interact with project

__init__.py tells that this directory is the python package.

settings.py contains all the configuration of the project like database connection, managing static urls and authentications etc.

wsgi.py, simple calling convention for web servers to forward requests to web applications or frameworks written in the Python programming language(HTTP request is recieved by web server of wsgi and sent to django as request in python form)

asgi.py, wsgi successor for async callable web servers.

urls.py defines the urls for the web apps.

To run the server, you need to run following command:

python manage.py runserver

Additionally, we can create an app for the specific purpose for example: if we are creating a blogging website an app for accounts managing users and all and another for blog posts can be maintained, the seperate app for specific task is easy managing and are portable too.

To create a django app.

python manage.py startapp app_name

It also has files like models.py, views.py, app.py, admin.py and we can create urls.py for managing the urls.

To understand how to create a basic django website : Django App Tutorial

Can we create an mobile application with Django?

The answer is no but yes, the django let us build the API which can be used in mobile app developement for backend.

We have django rest framework for creating the APIs for the backend which can be integrated with mobile apps, fronted web apps and desktop apps. Django is very useful when it comes to cross-platform applications developement. It offers top-notch handling and makes application scalable. Also, this feature ensures that the developer can manage things easily.

To learn more on django-rest-framework : Django Rest Framework

Django let us easy web development with abstraction but too much abstraction keep us away from understanding the basic important concepts.

So while learning Django and other frameworks never back yourself from asking how and understanding things, how it works.