Django Frontend

Django

Django is a framework that can make web applications more accessible and faster. Django is an open-source collection of python libraries, and Django can be used for both the front and back end. The Django Software Foundation maintains the Django framework. The framework is mainly known for the pluggability of its components; that is, its components can fit into any web application. Django uses the reusability of its components method; it is also known as the DRY (Don’t  Repeat Yourself ). Django also provides read, delete and update interfaces which can be used during the runtime of the process and these can be used dynamically. Many websites use the Django framework to create their web applications; some of them include:

  • Instagram
  • Mozilla
  • Clubhouse
  • Nextdoor

Django first came into work in 2003, when two scientists, Adrian Holovaty and Simon Willison, used the python libraries to create the web application. The Django was named after Django Reinhardt, who was aguitarist. In the year 2008, the Django Software Foundation was established, which will now maintain all the properties of Django.

The Django follows the MVT ( Model View template ) design pattern:

Model: The model collects the data from the databases and provides it to the user. SQL is mainly used to extract the data from the databases, but to use SQL, we need to have a greater command of the database structure. In Django, the method the data is delivered to the user with a technique is known as Object Relational Mapping (ORM) technique which is designed mainly to make the work easier. The models are located in the file models.py

View: The view is a kind of function which takes the HTTP requests as an argument, and with this, it will import the required models for the process and returns the data to the template, and it will return the final result. The view is generally located in the file views.py

Template: The templates are generally used to present the final result of the web application. The templates generally use the .html language to design the webpage layout; we can also use the other standard file formats. The templates of the file are usually located in the folder templates.

Django Frontend

To run Django, first, we need to have python installed on our computer, and then we need to check whether the package manager pip is installed or not on our computer. To check them, we need to run the following commands

Command:

python  --version
pip --version

If the python and the pip are already present on your computer, it will return the versions of the python and the pip.

Output:

Python 3.9
pip  18.9.4 from c:\python32\lib\site-packages\pip (python 3.9)

To create a folder of our project and a virtual environment, we need to use the help ofvenv. It will create a virtual environment, and then it will create a  folder “project” with other subfolders like libraries, scripts

Command:

py  -m venv project

Output:

project
    Include
    Lib
pyvenv.cfg

Now we need to activate the virtual environment by using this command:

project\Scripts\activate.bat

Output:

(project)  C:\Users\Nihaas >

Now we need to install Django on our computer with the help of the python install package (pip), with the command:

(project) C:Users\Nihaas >py – m pip install Django

 We can also check the version of python with the help of the following command

(project)  C:\Users\Nihaas>django-admin – version

Output:

3.9.0

 We need to set the name of our project, and then we need to run the following command,

django-admin  startprojectstudentsmarks

Output:

studentsmarks
     manage.py
studentsmarks/
	_init_.py
	asgi.py
	settings.py
	urls.py

Now we need to run our Django packager to check for the working of our browser. We need to go to the /studentsmarks folder, and then we need to execute the command:

py manage.py runserver

Output:       

Watching for file changes with StateReloder
Performing system checks….
System check identified no issues
You have 23  unapplied migrations. Your project may not work properly until you apply migrations for the web application: admin, sessions, auth
Run ‘python.manage.py.migrate’ to apply them
August 31, 2022 – 18:13:22
Django version 3.9.0, using settings ‘students marks.Settings’
Starting development server at http://134.0.1.0:7900/
Quit the server with CTRL-BREAK.

We can find our web application by opening the URL in the new browser in google.


Related Topics

Django Logging

Every application developed has some bugs and errors. It is the responsibility of the developers to maintain the application by making it bug-free and error-free. To debug the application code...

5 minutes read.

Django CSRF

Django is a high-level python based web framework. Django is open source and free to use for all. Django provides many features to web developers like scalability, security, rapid development,...

4 minutes read.

How to Implement Multiple User Types with Django

Django Framework: Django is a framework that can make web applications more accessible and faster. Django is an open-source collection of python libraries, and Django can be used for both the...

3 minutes read.

Creating View in Django

Creating View in Django    Django views are a key component of the frameworkbased applications.We are using Python function or class at their simplest, which takes up a web query and returns a web response.Views are used to get objects from the server, change objects if needed, render types, return HTML, and much more. Class Based View and Function based Django has two types of views: views based on functions (FBVs) and views based on class (CBVs).Initially, Django began with only FBVs, but then introduced CBVs as a way to model features so we didn't have to write boilerplate (i.e. the same software) code again and again.CBVs would be a way to increase efficiency, so you don't have to write as much code as you can. CBVs are classes of Python at their heart. Django ships with a range of "model" CBVs with pre-configured features that can be reused and often expanded.Then helpful names are given to these classes that explain what kind of functionality they provide.These are often referred to as "universal views" because they provide solutions to specific needs. The classes have a journal View function, or "view" for short, is simply a Python program that uses a web query and returns a web response. This response may include the HTML content of a web page, or a redirect, or a 404 error, or an XML file, or an image, etc. Example: You use a view to create a web page, remember that you need to connect a view to a URL to see it as a web page. Simple View We will create a simple view in myapplication to say “Welocome to django application” See the following view – from django.http import HttpResponse ...

4 minutes read.

Django Celery

Django is a python-based web framework. It is an open-source and free-to-use framework. Django uses the Model View Template architecture. Django provides many functionalities to web developers. One of these...

3 minutes read.

Django Create Project

Django is an open-source free to use web framework which is based on Python. Django uses Model-View-Template as its architecture. The final version of Django was released in 2008. Django...

4 minutes read.

Django REST Framework

Django REST Framework (DRF)is an open-source, powerful, and flexible toolkit used to build RESTful web APIs. It is built upon the Django framework. DRF increases the development speed. Django and...

4 minutes read.

Django Image Upload

Django is a python based web framework that uses Model View Template as its architecture. Django provides really quick web development with its functionalities. While we are building a website,...

3 minutes read.

Django Pagination

Django is an open-source free to use python based web framework. Django provides many inbuilt tools for web developers to provide rapid web development. One of these tools is pagination....

4 minutes read.

Life Cycle of Django

Life Cycle of Django Request - Response life cycle in Django  Thebasic principle of http protocol is the client sends a request to the server based on the request data, and the server sends...

3 minutes read.

How to create an app in Django

Create an application in Django Django is famous for its unique and fully managed application structure. For each functionality, an application can be created as a completely independent module. This article will take...

2 minutes read.

Django MVT

 MVT(Model View Template) MVT means Model View Template is a software design pattern The View is used to implement the business logic and to communicate with a model for data transmission and to...

2 minutes read.

How to Uninstall Django from cmd

Python is an interactive and more accessible language than any other programming language. The python programming language uses a variety of libraries to perform the operations in a faster way....

3 minutes read.

Django Template System

Django Template System Django allows Python and HTML to be divided, the Python goes into views, and HTML goes into templates. Django relies on the render feature and the language of the Django Model...

5 minutes read.

Uses of Django

Django is a free and open-source Python-based web framework, which offers great functionalities to its users. Django was developed in 2003, and the final version was released in 2008 by...

3 minutes read.

Django Model

Django Model A template is a class representing a table or collection in our DB and where each class attribute is a table or collection area. In the app / models.py, models are...

6 minutes read.

Django Installation

Django Installation Django development environment consists of installing and setting up Python, Django, and a Database System since Django deals with a web application. Below the statement will guide you through installing Python 3.8.0 and...

2 minutes read.

Django Project

Django Project Let's start to use it. Each web app you want to build in Django is called a project; and a project is a collection of apps. A software is a series of...

3 minutes read.

Django Forms

Django is a Python Programming Open Source framework for web development. It was released in 2008 and was developed by two web developers named Adrian Holovaty and Simon Willison. It...

3 minutes read.

Django Filters

Django is a high-level python based web framework. Django is mostly used as a backend engine for websites. Nowadays, every website communicates to a database to fetch all the information...

3 minutes read.