<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Praseesh P</title>
    <description>The latest articles on DEV Community by Praseesh P (@praseesh_p_).</description>
    <link>https://dev.to/praseesh_p_</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F2056106%2F14db1596-44c0-43b9-9179-db712c65636f.jpg</url>
      <title>DEV Community: Praseesh P</title>
      <link>https://dev.to/praseesh_p_</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/praseesh_p_"/>
    <language>en</language>
    <item>
      <title>Mastering Python Logging: From Basics to Advanced Techniques</title>
      <dc:creator>Praseesh P</dc:creator>
      <pubDate>Tue, 03 Dec 2024 16:03:16 +0000</pubDate>
      <link>https://dev.to/praseesh_p_/mastering-python-logging-from-basics-to-advanced-techniques-50f1</link>
      <guid>https://dev.to/praseesh_p_/mastering-python-logging-from-basics-to-advanced-techniques-50f1</guid>
      <description>&lt;p&gt;Logging in Python is more than just debugging—it's about tracking, monitoring, and understanding your application’s behavior. Whether you're a beginner or an experienced developer, this guide covers all aspects of logging, from basic setups to advanced techniques.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fmxceu7j233n8c6hlqwtl.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fmxceu7j233n8c6hlqwtl.jpeg" alt="Image description" width="800" height="418"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Introduction&lt;/strong&gt;&lt;br&gt;
What is logging?&lt;br&gt;
Logging is a mechanism to record and track events during the execution of a program, helping developers debug, monitor, and analyze their applications effectively.&lt;/p&gt;

&lt;p&gt;Why is logging essential?&lt;br&gt;
Unlike print, logging offers flexibility, scalability, and configurability, making it a robust choice for both small scripts and large applications.&lt;/p&gt;

&lt;p&gt;What this blog covers&lt;br&gt;
Setting up basic logging&lt;br&gt;
Writing logs to files&lt;br&gt;
Creating custom loggers&lt;br&gt;
Formatting log outputs&lt;br&gt;
Advanced techniques like log rotation and configurations&lt;br&gt;
Best practices and common mistakes&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What is Logging in Python?&lt;/strong&gt;&lt;br&gt;
Introduce the logging module.&lt;br&gt;
Explain logging levels:&lt;br&gt;
&lt;strong&gt;DEBUG&lt;/strong&gt;: Detailed information for diagnosing issues.&lt;br&gt;
&lt;strong&gt;INFO&lt;/strong&gt;: Confirmation that the program is working as expected.&lt;br&gt;
&lt;strong&gt;WARNING&lt;/strong&gt;: Something unexpected happened, but the program can still run.&lt;br&gt;
&lt;strong&gt;ERROR&lt;/strong&gt;: A problem caused an operation to fail.&lt;br&gt;
&lt;strong&gt;CRITICAL&lt;/strong&gt;: A serious error that might stop the program.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Setting Up Basic Logging&lt;/strong&gt;&lt;br&gt;
Introduce logging.basicConfig.&lt;br&gt;
Provide a simple example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import logging

# Basic configuration
logging.basicConfig(level=logging.INFO)

# Logging messages
logging.debug("Debug message")
logging.info("Info message")
logging.warning("Warning message")
logging.error("Error message")
logging.critical("Critical message")
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Output&lt;br&gt;
By default, only messages at WARNING level or above are displayed on the console. The above example produces:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;WARNING:root:Warning message&lt;br&gt;
ERROR:root:Error message&lt;br&gt;
CRITICAL:root:Critical message&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Writing Logs to a File&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;logging.basicConfig(filename="app.log", 
                    level=logging.DEBUG, 
                    format="%(asctime)s - %(levelname)s - %(message)s")

logging.info("This will be written to a file.")
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Explain common parameters in basicConfig:&lt;br&gt;
&lt;strong&gt;filename&lt;/strong&gt;: Specifies the log file.&lt;br&gt;
&lt;strong&gt;filemode&lt;/strong&gt;: 'w' to overwrite or 'a' to append.&lt;br&gt;
&lt;strong&gt;format&lt;/strong&gt;: Customizes log message structure.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Creating Custom Loggers&lt;/strong&gt;&lt;br&gt;
Why use custom loggers? For modular and more controlled logging.&lt;br&gt;
Example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import logging

# Create a custom logger
logger = logging.getLogger("my_logger")
logger.setLevel(logging.DEBUG)

# Create handlers
console_handler = logging.StreamHandler()
file_handler = logging.FileHandler("custom.log")

# Set levels for handlers
console_handler.setLevel(logging.INFO)
file_handler.setLevel(logging.ERROR)

# Create formatters and add them to handlers
formatter = logging.Formatter("%(name)s - %(levelname)s - %(message)s")
console_handler.setFormatter(formatter)
file_handler.setFormatter(formatter)

# Add handlers to the logger
logger.addHandler(console_handler)
logger.addHandler(file_handler)

# Log messages
logger.info("This is an info message.")
logger.error("This is an error message.")
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;** Formatting Logs**&lt;br&gt;
Explain log record attributes:&lt;br&gt;
%(asctime)s: Timestamp.&lt;br&gt;
%(levelname)s: Level of the log message.&lt;br&gt;
%(message)s: The actual log message.&lt;br&gt;
%(name)s: Logger's name.&lt;br&gt;
Advanced formatting:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;logging.basicConfig(format="%(asctime)s - %(name)s - %(levelname)s - %(message)s",
                    datefmt="%Y-%m-%d %H:%M:%S",
                    level=logging.DEBUG)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Log Rotation&lt;/strong&gt;&lt;br&gt;
Introduce RotatingFileHandler for managing log file size.&lt;br&gt;
Example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;from logging.handlers import RotatingFileHandler

# Create a logger
logger = logging.getLogger("rotating_logger")
logger.setLevel(logging.DEBUG)

# Create a rotating file handler
handler = RotatingFileHandler("app.log", maxBytes=2000, backupCount=3)
formatter = logging.Formatter("%(asctime)s - %(levelname)s - %(message)s")
handler.setFormatter(formatter)

logger.addHandler(handler)

# Log messages
for i in range(100):
    logger.info(f"Message {i}")
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Using logging.config for Complex Configurations&lt;/strong&gt;&lt;br&gt;
Show how to use a configuration dictionary:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import logging
import logging.config

log_config = {
    "version": 1,
    "formatters": {
        "default": {
            "format": "%(asctime)s - %(name)s - %(levelname)s - %(message)s"
        }
    },
    "handlers": {
        "console": {
            "class": "logging.StreamHandler",
            "formatter": "default"
        },
        "file": {
            "class": "logging.FileHandler",
            "filename": "config.log",
            "formatter": "default"
        }
    },
    "loggers": {
        "": {  # Root logger
            "handlers": ["console", "file"],
            "level": "INFO"
        }
    }
}

logging.config.dictConfig(log_config)
logger = logging.getLogger("custom_logger")
logger.info("This is a log from the configured logger.")

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Best Practices for Logging&lt;/strong&gt;&lt;br&gt;
Use meaningful log messages.&lt;br&gt;
Avoid sensitive data in logs.&lt;br&gt;
Use DEBUG level in development and higher levels in production.&lt;br&gt;
Rotate log files to prevent storage issues.&lt;br&gt;
Use unique logger names for different modules.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Common Mistakes&lt;/strong&gt;&lt;br&gt;
Overusing DEBUG in production.&lt;br&gt;
Forgetting to close file handlers.&lt;br&gt;
Not using a separate log file for errors.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Advanced Topics&lt;/strong&gt;&lt;br&gt;
Asynchronous Logging&lt;br&gt;
For high-performance applications, use QueueHandler to offload logging tasks asynchronously.&lt;/p&gt;

&lt;p&gt;Structured Logging&lt;br&gt;
Log messages as JSON to make them machine-readable, especially for systems like ELK Stack.&lt;/p&gt;

&lt;p&gt;Third-Party Libraries&lt;br&gt;
Explore tools like &lt;a href="https://loguru.readthedocs.io/en/stable/" rel="noopener noreferrer"&gt;loguru&lt;/a&gt; for simpler and more powerful logging.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Conclusion&lt;/strong&gt;&lt;br&gt;
Logging is not just about debugging—it's about understanding your application. By mastering Python's logging module, you can ensure your projects are robust, maintainable, and easy to debug.&lt;/p&gt;

&lt;p&gt;Have questions or suggestions? Share your thoughts in the comments below!&lt;/p&gt;

</description>
      <category>python</category>
      <category>django</category>
      <category>restapi</category>
      <category>logging</category>
    </item>
    <item>
      <title>Integrating Redis with Django for High-Performance Caching</title>
      <dc:creator>Praseesh P</dc:creator>
      <pubDate>Mon, 04 Nov 2024 15:08:43 +0000</pubDate>
      <link>https://dev.to/praseesh_p_/integrating-redis-with-django-for-high-performance-caching-490b</link>
      <guid>https://dev.to/praseesh_p_/integrating-redis-with-django-for-high-performance-caching-490b</guid>
      <description>&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fhhnon1en7g9yxcli2y9x.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fhhnon1en7g9yxcli2y9x.png" alt="Image description" width="800" height="571"&gt;&lt;/a&gt;&lt;br&gt;
In modern web applications, performance and responsiveness are crucial. As traffic increases, the demand for efficient data handling and quick response times grows. Using Redis with Django for caching can significantly enhance application performance. In this post, I’ll walk through integrating Redis with Django and explore core concepts like Redis, SQL vs. NoSQL databases, caching, and why these elements are important in backend development.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What is Redis?&lt;/strong&gt;&lt;br&gt;
Redis (Remote Dictionary Server) is an open-source, in-memory data structure store that can be used as a database, cache, and message broker. It’s known for its speed, as it stores data in memory rather than on disk, making it ideal for applications that require real-time data access.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Redis Key Features:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Data Persistence&lt;/strong&gt;: Redis supports in-memory storage but can persist data to disk.&lt;br&gt;
&lt;strong&gt;Data Types&lt;/strong&gt;: Redis supports multiple data structures like strings, hashes, lists, sets, sorted sets, and more.&lt;br&gt;
Atomic Operations: Redis operations are atomic, meaning they’re completed without interruption, which is crucial for consistency.&lt;br&gt;
&lt;strong&gt;Scalability&lt;/strong&gt;: Redis can be used in distributed environments for horizontal scaling, allowing you to handle increased loads efficiently.&lt;br&gt;
&lt;strong&gt;What is Caching?&lt;/strong&gt;&lt;br&gt;
Caching temporarily stores data in memory so that it can be retrieved faster in future requests. Caching is especially beneficial for data that doesn’t change often, such as user session data, product catalogs, or frequent API responses. With caching, you reduce the number of database queries, leading to faster response times.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Types of Caching:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Database Caching&lt;/strong&gt;: Storing frequently accessed database query results in cache.&lt;br&gt;
&lt;strong&gt;View Caching&lt;/strong&gt;: Caching the entire rendered HTML for a view.&lt;br&gt;
&lt;strong&gt;Session Caching&lt;/strong&gt;: Using Redis to store session data, allowing for faster session retrieval in web applications.&lt;br&gt;
SQL vs. NoSQL Databases&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F1an2wphrpp4wodvetvwz.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F1an2wphrpp4wodvetvwz.png" alt="Image description" width="800" height="515"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;SQL Databases&lt;/strong&gt;&lt;br&gt;
SQL (Structured Query Language) databases are relational, meaning they store data in tables with predefined schemas. They’re known for their ACID (Atomicity, Consistency, Isolation, Durability) properties, ensuring data reliability.&lt;/p&gt;

&lt;p&gt;Examples: PostgreSQL, MySQL, SQLite&lt;br&gt;
Best Suited For: Applications requiring complex querying, transactions, or structured data.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;NoSQL Databases&lt;/strong&gt;&lt;br&gt;
NoSQL databases are non-relational and offer flexible schemas, making them ideal for handling large volumes of unstructured or semi-structured data. NoSQL databases are often used in distributed and large-scale environments.&lt;/p&gt;

&lt;p&gt;Examples: MongoDB, Cassandra, Redis&lt;br&gt;
Best Suited For: High-speed operations, flexibility, scalability, and applications that need to handle large volumes of unstructured data.&lt;br&gt;
Integrating Redis with Django for Caching&lt;br&gt;
Using Redis as a caching layer in Django is straightforward, thanks to django-redis, a dedicated package that integrates Redis with Django’s caching framework.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Install django-redis&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;pip install django-redis
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Configure Redis as a Cache Backend in Django&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;In settings.py, configure django-redis as your caching backend:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;CACHES = {
    'default': {
        'BACKEND': 'django_redis.cache.RedisCache',
        'LOCATION': 'redis://127.0.0.1:6379/1',
        'OPTIONS': {
            'CLIENT_CLASS': 'django_redis.client.DefaultClient',
        }
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Using Redis Cache in Django&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;from django.core.cache import cache

# Set cache data
cache.set('key', 'value', timeout=60*15)  # 15 minutes

# Retrieve cache data
value = cache.get('key')

# Delete cache data
cache.delete('key')
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Caching Views&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;For pages that don’t change often, you can cache the entire view:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;from django.shortcuts import HttpResponse
from django.core.cache import cache

def cache_set_get(request): # Cache for 1 minutes
    cache.set('orange', '100', timeout=60) #Here "orange" is the key and "100" is the value
    value = cache.get('orange') 
    print(f'Orange: {value}')

    # cache.delete('orange')

    return HttpResponse(f'Orange value: {value}')
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;urls.py&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;from django.urls import path
from . import views
urlpatterns = [
    path('cache_set_get_/', views.cache_set_get_, name='cache_set_get')
]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Why Use Redis with Django?&lt;br&gt;
Performance: Redis drastically reduces database load by storing frequently accessed data in memory.&lt;br&gt;
Scalability: Redis can scale horizontally to handle more requests.&lt;br&gt;
Simplicity: Redis integrates easily with Django, providing a straightforward way to add caching without significant code changes.&lt;br&gt;
Versatility: Redis supports multiple data structures and can be used for sessions, task queues, leaderboards, and more.&lt;br&gt;
Redis is a powerful tool that enhances Django’s capabilities, making it possible to build high-performance, scalable applications. By leveraging Redis caching, you reduce the load on your database, improve response times, and enhance the user experience. Whether you’re new to caching or exploring Django’s advanced features, Redis is a valuable addition to your toolkit.&lt;/p&gt;

&lt;p&gt;Additional Resources&lt;br&gt;
&lt;a href="https://redis.io/docs/latest/" rel="noopener noreferrer"&gt;Official Redis Documentation&lt;/a&gt;&lt;br&gt;
&lt;a href="https://django-redis.readthedocs.io/en/stable/" rel="noopener noreferrer"&gt;Django Redis Documentation&lt;/a&gt;&lt;br&gt;
&lt;a href="https://docs.djangoproject.com/en/5.1/topics/cache/" rel="noopener noreferrer"&gt;Understanding Caching in Django&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;thank you for reading….&lt;/p&gt;

</description>
      <category>python</category>
      <category>django</category>
      <category>redis</category>
      <category>nosql</category>
    </item>
    <item>
      <title>Django Request/Response Life Cycle</title>
      <dc:creator>Praseesh P</dc:creator>
      <pubDate>Sun, 03 Nov 2024 05:16:42 +0000</pubDate>
      <link>https://dev.to/praseesh_p_/django-requestresponse-life-cycle-4lpd</link>
      <guid>https://dev.to/praseesh_p_/django-requestresponse-life-cycle-4lpd</guid>
      <description>&lt;p&gt;The Django request-response cycle is a fundamental process that defines how Django handles requests and delivers responses to users. Below is a detailed breakdown of each step, illustrated with an easy-to-follow diagram.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F3k22at5zoofig5w6ek7r.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F3k22at5zoofig5w6ek7r.gif" alt="Image description" width="798" height="935"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The Request-Response Flow&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. Client (Browser) → Web Server (Nginx/Apache):&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;A user initiates a request from a browser, which is forwarded to a web server like Nginx or Apache.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2. Web Server → WSGI (Gunicorn/wsgi.py):&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The web server forwards the request to WSGI (Web Server Gateway Interface), an application server that bridges the web server and Django.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;3. Request Middleware:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The WSGI server sends the request to Django’s middleware. Middleware components are functions that process requests before they reach the view or responses before they’re sent back to the client.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;4. URL Resolution (urls.py):&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Django resolves the requested URL through urls.py to find the appropriate view function.&lt;/p&gt;

&lt;p&gt;*&lt;em&gt;5. View (views.py) with Middleware:&lt;br&gt;
*&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;The view function associated with the URL is executed. Middleware can also intercept the response from the view before it proceeds.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;6. Model (models.py) and Database (PostgreSQL):&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;If the view needs to access data, it interacts with the database through Django’s models and managers.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;7. Response Preparation:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The view returns a response, which might involve rendering an HTML template or other data (like JSON in an API response).&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;8. Template Middleware:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Middleware can again modify the response before it goes back to the WSGI server.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;9. Exception Middleware:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;If any error occurs, Exception Middleware will handle and display it appropriately.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;10. Response Middleware → WSGI → Web Server → Client:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The response goes back through the WSGI server and the web server before reaching the client’s browser.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Key Components in Django’s Cycle&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Request and Response Middleware: Manages request/response transformations.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;WSGI&lt;/strong&gt;: Acts as a bridge between the web server and Django.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Views, Models, and Managers&lt;/strong&gt;: Core parts of Django’s MVC architecture.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Templates&lt;/strong&gt;: Used for rendering HTML responses.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Database&lt;/strong&gt;: The source of stored data, commonly PostgreSQL in Django setups.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Thanks For Reading… 😍&lt;/em&gt;&lt;/p&gt;

</description>
      <category>python</category>
      <category>django</category>
      <category>softwaredevelopment</category>
      <category>webdev</category>
    </item>
  </channel>
</rss>
