DJANGO — An Overview

Radhika Agrawal
funccFORCE
Published in
4 min readApr 7, 2021

Django is an open-source and free Python web application written in Python language, which we use in developing web applications.

Django is easy to learn with the help of the combination of great and a lively community.

Why I chose Django?

Django, a Python-based web application/framework, is my favorite choice for web apps for several reasons are Writing, extending, troubleshooting, testing, and securing, making for a quick and effective development process is very easy in Django.

As we know that in web applications Security is very important, so for security Django offers features such as checking user permissions before rendering the view and CSRF tokens in forms.

Even though Django is good but sometimes I need to add extra tech to my frontend stack. Though that is easy work to do with Django as it works really well with many frontend platforms.

Django is built with support for testing in mind, it’s possible to write separate unit tests for each Django application within one project.

How is Django different from other frameworks?

Django framework has more code-reusability than other frameworks. It is a collection of different applications like login and signup applications.

These applications can be just copied from one directory to another with some tweaks to the settings.py file and we won’t need to write a new signup application from scratch.

This is why Django is known as a rapid development framework and other frameworks don’t have this level of code reusability.

A Django project consists of these five files:

· manage.py

· settings.py

· __init__.py

· urls.py

· wsgi.py

These files are inside a directory, which is at the same level as the manage.py file.

manage.py: It is the command-line utility of our Django project and this file is used to control our Django project on the server or even to begin one.

settings.py: This python file contains information on all our applications that are being installed in our project, database connections, and the path to the main URL configuration.

urls.py: This python file works for examining the URLs and calling the right view function or transporting the URL to another application-specific URLs-configuring file.

__init__.py: __init__.py file is an empty file for making the python interpreter understand that the directory consisting of settings.py is a package.

wsgi.py: This file is for the server format WSGI, which is supported by Django. It can be customized for some other server formats.

What are View functions?

The View is the Django component that receives data from the Django models and passes the same data to the Templates. views.py file comes in every application in Django containing the View functions.

The View functions are those functions that work for receiving an argument and then return a browser-renderable format or a redirect.

Django Views function can be directly imported into URL files.

For that, we have to first import the view function in the urls.py file and then add the path or URL to call that View function.

urls.py

Here as you can see that I imported all the functions from my View module which is in the same folder.

I added the URL in the URL patterns list. When the ‘dataflair/’ gets searched, I have called a function named index.

What is the Django.shortcuts.render function?

The render() is used when a View function returns a webpage as HttpResponse rather than a simple string

Render function is basically a shortcut function that lets the developer easily pass the data dictionary with the template.

The render() returns an HttpResponse with the rendered text, which is the data returned by the models.

Thus, Django render() bypasses lots of work for the developers and lets us use different templating engines.

The basic render Syntax is as follows: render(request, template_name)

views.py

The request is basically the parameter that will generate the response and the template_name containing the value where the template is being stored.

The template name and other parameters are used for passing the dictionary.

If we want more control, we can specify the content type, the status of the data we passed, and the render we are returning. This was all about the render().

I hope this blog will help you. If I got something wrong? Let me know in the comments. I would love to improve.

--

--