Dynamic filtration method in Django
Introduction – What is Django ?
The Django web framework is a free, open source framework that can speed up development of a web application being built in the Python programming language.
Django—pronounced “Jango,” named after the famous jazz guitarist Django Reinhardt—is a free, open source framework that was first publicly released in 2005. Django facilitates “rapid development and clean, pragmatic design.” The Django web framework, deployed on a web server, can help developers quickly produce a web frontend that’s feature-rich, secure and scalable.
Starting with the Django web framework is more efficient way to build a web app than starting from scratch, which requires building the backend, APIs, javascript and sitemaps. With the Django web framework, web developers can focus on creating a unique application and benefit from greater flexibility than using a web development tool.
Getting to know the Django web framework
Do you need more information to discover what is Django and how it's used? Do you
want some hands-on experience working with a web app created using the Django
pip install django
web framework? IBM offers a step-by-step tutorial for using IBM Cloud services to
track activity and monitor the health of a Python-based Kubernetes application
written using the Django web framework and running on the IBM Cloud.
With all the Python web frameworks to choose from, why pick Django web
framework? It might not be the easiest to use and it’s certainly not the newest.
Nevertheless, the Django web framework might be the right fit when you’re building a
web app that’s involves cross-site scripting and is expected to handle a large number
of users or a complex set of features, such as API connectivity or user
authentication. Based on the number of projects on GitHub, it's also very popular.
Anyone proficient in the Python programming language and its syntax should be able
to start a project using Django web framework to build a web app. (Note: While most
of Django core is Python, the admin and gis contrib apps contain JavaScript code.)
However, intermediate to advanced Django developers can better capitalize on
Django models, which are more sophisticated features.
Packaging essential features
Django web framework has been in use for more than a decade and has been
thoroughly tested and enhanced by a very active community. It even has a non-
profit; the Django software foundation promotes, supports and advances the Django
web framework. Django’s greatest strength is its large feature set—with more than
10,000 Django packages, the framework covers virtually anything you’ll need a web
application to do. Packages include APIs, content management systems, user
authentication, form validation and CAPTCHA protection.
The user base for Django web framework is supportive and dedicated, full of talented
Django developers volunteering their time and expertise to develop, improve and
patch the Django software foundation. Your application can benefit from this
commitment by tapping into the well-designed packages available to anyone building
with Django.
Basic flows of the project
What is AJAX?
AJAX stands for “Asynchronous JavaScript and XML”. It isn’t a single, nor a new technology. In fact, it is a group of existing technologies (i.e. HTML, CSS, JavaScript, XML, etc.) which come together to build modern web applications.
With AJAX, a client (i.e. browser) communicates with a web server and asks for data. Then, it processes the server’s response and make changes to the page without fully reloading it.
Let’s break down the AJAX acronym:
· “Asynchronous” means that when a client requests data from a web server, it doesn’t freeze until the server replies. On the contrary, the user can still navigate the pages. As soon as the server returns a response, a relevant function manipulates the returned data behind the scenes.
· “JavaScript” is the language which instantiates an AJAX request, parses the corresponding AJAX response, and finally updates the DOM.
· A client uses the XMLHttpRequest or XHR API to make a request to a server. Think of the API (Application Programming Interface) as a set of methods which specify the rules of communication between the two interested parties. However, note that the incoming data from an AJAX request can be in any format and not only in XML format.
This visualization describes a typical AJAX-driven scenario:
· The user wants to see more articles, so he or she clicks on the target button. This event triggers an AJAX call.
· A request is sent to the server. Along with the request, different data may be passed. The request can point to a static file (e.g. example.json) which is stored on the server. Alternatively, it’s possible to execute a dynamic script (e.g. functions.php) at which point the script talks to the database (or other system) to retrieve data.
· The database sends back the requested articles to the server. Next, the server sends them to the browser.
Recommended by LinkedIn
· JavaScript parses the response and updates specific parts of the DOM (the page structure). Here, for instance, only the sidebar is being updated. The other parts of the page don’t change.
Dataset Filtering:
We collect all the data using django-import-export module.
Here is some details about django-import-export module.
django-import-export library provides an import_export app for your Django
project. You can use the import_export app with Django Admin. It will simply add
fully functional import and export buttons to the admin dashboard.
Model data can be imported from CSV, XML, Excel, JSON, etc. You may also export
data to multiple file formats like CSV, XLS, TSV, ODS, JSON, YAML, and HTML.
You may easily add the import_export app in 4 easy steps:
· Step 1: Install django-import-export via pip
·
· Step 2: Add import_export to INSTALLED_APPS in settings.py
·
· Step 3: Import and inherit ImportExportModelAdmin in admin.py
·
· Step 4: Set import_export app permissions under settings.py (if needed)
Data collected from in xlsx or csv format using django-import-export module and data’s are directly save into database.
For data filtering we use django queryset filtering method.
A QuerySet represents a collection of objects from your database. It can have zero, one or many filters. Filters narrow down the query results based on the given parameters. In SQL terms, a QuerySet equates to a SELECT statement, and a filter is a limiting clause such as WHERE or LIMIT.
We filter all the data based on VP, PSD, CM, BPG, DEPARTMENT, and CLASS.
we take all the data from database like,
and send the vp filter data in frontend.
Then selected data we got from post method using ajax.
after filtering VP data, we filter PSD data based on VP data like,
after filtering PSD data, we filter CM data based on PSD data like,
after filtering CM data, we filter BPG data based on CM data like,
after filtering BPG data, we filter DEPARTMENT data based on BPG data like,
after filtering DEPARTMENT data, we filter CLASS data based on DEPARTMENT data like,
Here using this method all filtering process completed.
Advantages:
· From the front end we can short and filter data same as excel.
· The excel feature "filter" is a very important feature as it saves time & reduces workload
· Filters are used to find all records matching a certain criterion at one place
ESRI-GIS Developer @ TCS || Data Engineer || 2×Azure || PySpark || ESRI Suit || JavaScript API for ArcGIS || GeoPandas
3yNicely written and insightful!
5 ⭐ in C++ @Hackerrank || Full Stack Developer with >3 yrs of experience || Competitive Programming enthusiast
3yWow ! This article is so insightful Soumya Ghatak bhaiya 😊