<?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: Gopal Ghate</title>
    <description>The latest articles on DEV Community by Gopal Ghate (@gopal_ghate_5bda01b730e45).</description>
    <link>https://dev.to/gopal_ghate_5bda01b730e45</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%2F3519355%2Ff1b2fee1-1fae-4239-9e75-29922b281990.png</url>
      <title>DEV Community: Gopal Ghate</title>
      <link>https://dev.to/gopal_ghate_5bda01b730e45</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/gopal_ghate_5bda01b730e45"/>
    <language>en</language>
    <item>
      <title>🧱 Django Class-Based Views (CBVs) – Building APIs for the Frontend</title>
      <dc:creator>Gopal Ghate</dc:creator>
      <pubDate>Mon, 13 Oct 2025 17:52:21 +0000</pubDate>
      <link>https://dev.to/gopal_ghate_5bda01b730e45/django-class-based-views-cbvs-building-apis-for-the-frontend-38h4</link>
      <guid>https://dev.to/gopal_ghate_5bda01b730e45/django-class-based-views-cbvs-building-apis-for-the-frontend-38h4</guid>
      <description>&lt;p&gt;In this article, we’ll explore how Class-Based Views (CBVs) can be used to build clean, reusable APIs instead of rendering templates.&lt;/p&gt;

&lt;h3&gt;
  
  
  💡 What Are Class-Based Views?
&lt;/h3&gt;

&lt;p&gt;Class-Based Views (CBVs) allow you to organize request-handling logic using Python classes instead of functions. They provide structure and reusability for common API operations such as fetching lists, retrieving single records, creating, updating, and deleting data.&lt;/p&gt;

&lt;p&gt;Example – converting FBV to CBV:&lt;br&gt;
&lt;strong&gt;Function Based View&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.http import JsonResponse

def home(request):
    return JsonResponse({"message" : Welcome to My Blog API"})
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Class Based view&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.views import View
from django.http import JsonResponse

class HomeView(View):
    def get(self, request):
        return JsonResponse({"message": "Welcome to My Blog API!"})
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And in urls.py&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 .views import HomeView


urlpatterns = [
    path('', HomeView.as_view(), name='home'),
]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;as_view() converts the class into a callable function that Django can handle.&lt;/p&gt;

&lt;h3&gt;
  
  
  ⚙️ Example: API CRUD Using CBVs
&lt;/h3&gt;

&lt;p&gt;Let's say we have a simple Post models:&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.db import models

class Post(models.Model):
    title = models.CharField(max_length=200)
    content = models.TextField()
    created_at = models.DateTimeField(auto_now_add=True)

def __str__(self):
    return self.title

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

&lt;/div&gt;



&lt;p&gt;We’ll create CBVs for each CRUD operation and return JSON responses.&lt;/p&gt;

&lt;h4&gt;
  
  
  1️⃣ ListView – Get All Posts
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;class PostListView(View):
    def get(self, request):
        posts = list(Post.objects.values())
        return JsonResponse({"posts": posts})
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  2️⃣ DetailView – Get a Single Post
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;class PostDetailView(View):
    def get(self, request, pk):
        try:
            post = Post.objects.values().get(id=pk)
            return JsonResponse({"post": post})
        except Post.DoesNotExist:
            return HttpResponseNotFound(JsonResponse({"error": "Post not found"}))
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;3️⃣ CreateView – Add a New Post&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;@method_decorator(csrf_exempt, name='dispatch')
class PostCreateView(View):
    def post(self, request):
        data = json.loads(request.body)
        post = Post.objects.create(title=data.get('title'), content=data.get('content'))
        return JsonResponse({"id": post.id, "message": "Post created successfully"}, status=201)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;4️⃣ UpdateView – Edit an Existing Post&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
@method_decorator(csrf_exempt, name='dispatch')
class PostUpdateView(View):
    def put(self, request, pk):
        try:
            post = Post.objects.get(id=pk)
            data = json.loads(request.body)
            post.title = data.get('title', post.title)
            post.content = data.get('content', post.content)
            post.save()
            return JsonResponse({"message": "Post updated successfully"})
        except Post.DoesNotExist:
            return JsonResponse({"error": "Post not found"}, status=404)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  5️⃣ DeleteView – Remove a Post
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
@method_decorator(csrf_exempt, name='dispatch')
class PostDeleteView(View):
    def delete(self, request, pk):
        try:
            post = Post.objects.get(id=pk)
            post.delete()
            return JsonResponse({"message": "Post deleted successfully"})
        except Post.DoesNotExist:
            return JsonResponse({"error": "Post not found"}, status=404)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  🧠 Why CBVs Are Great for APIs
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Cleaner, more structured code.&lt;/li&gt;
&lt;li&gt;Each HTTP method has its own function (get, post, put, delete).&lt;/li&gt;
&lt;li&gt;Easy to extend and reuse logic using inheritance.&lt;/li&gt;
&lt;li&gt;Plays nicely with Django REST Framework if you decide to scale up.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  ⚡ Best Practices
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Always return JSON for frontend consumption.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Use csrf_exempt carefully or rely on proper CSRF tokens for POST/PUT requests.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Validate input data before saving.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Use Django REST Framework for complex APIs with authentication, pagination, and serializers.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  🏆 Summary
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;CBVs can be used not only for HTML rendering but also for clean API design.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Each request type (GET, POST, PUT, DELETE) can be handled within a single class.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Use CBVs for modular, maintainable, and testable backend APIs.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>webdev</category>
      <category>django</category>
      <category>api</category>
      <category>backend</category>
    </item>
    <item>
      <title>🎨 Django Templates &amp; Static Files – Building Dynamic HTML</title>
      <dc:creator>Gopal Ghate</dc:creator>
      <pubDate>Sun, 05 Oct 2025 10:52:48 +0000</pubDate>
      <link>https://dev.to/gopal_ghate_5bda01b730e45/django-templates-static-files-building-dynamic-html-article-5-41cb</link>
      <guid>https://dev.to/gopal_ghate_5bda01b730e45/django-templates-static-files-building-dynamic-html-article-5-41cb</guid>
      <description>&lt;p&gt;In the last article, we learned how to handle views and return different types of responses. Now, let’s make those responses beautiful and dynamic using Django Templates and Static Files.&lt;/p&gt;

&lt;p&gt;Templates allow you to mix HTML with Python-like logic, and static files (CSS, JS, images) make your pages come alive.&lt;/p&gt;

&lt;h3&gt;
  
  
  🧩 What Are Django Templates?
&lt;/h3&gt;

&lt;p&gt;Django uses the Django Template Language (DTL) to help you embed dynamic content inside HTML.&lt;br&gt;
Example (blog/templates/blog/home.html):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;!DOCTYPE html&amp;gt;
&amp;lt;html&amp;gt;
    &amp;lt;head&amp;gt;
        &amp;lt;title&amp;gt;{{ title }}&amp;lt;/title&amp;gt;
    &amp;lt;/head&amp;gt;
    &amp;lt;body&amp;gt;
        &amp;lt;h1&amp;gt;Welcome, {{ user }}&amp;lt;/h1&amp;gt;
        &amp;lt;p&amp;gt;{{ message }}&amp;lt;/p&amp;gt;
    &amp;lt;/body&amp;gt;
&amp;lt;/html&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can pass variables from your view:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;def home(request):
    context = {
    'title': 'My Blog',
    'user': 'Gopal',
    'message': 'Learning Django Templates is fun!'
    }
    return render(request, 'blog/home.html', context)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Result -&amp;gt; Welcome, Gopal&lt;/p&gt;

&lt;h3&gt;
  
  
  🧠 Template Tags and Filters
&lt;/h3&gt;

&lt;p&gt;You can use logic in templates using special tags.&lt;br&gt;
&lt;strong&gt;Example&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;{% if user %}
    &amp;lt;h2&amp;gt;Hello, {{ user }}!&amp;lt;/h2&amp;gt;
{% else %}
    &amp;lt;h2&amp;gt;Welcome, Guest!&amp;lt;/h2&amp;gt;
{% endif %}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Loops&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;&amp;lt;ul&amp;gt;
    {% for post in posts %}
        &amp;lt;li&amp;gt;{{ post.title }}&amp;lt;/li&amp;gt;
    {% empty %}
    &amp;lt;li&amp;gt;No posts available.&amp;lt;/li&amp;gt;
    {% endfor %}
&amp;lt;/ul&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Filters&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;&amp;lt;p&amp;gt;{{ post.content|truncatewords:10 }}&amp;lt;/p&amp;gt;
&amp;lt;p&amp;gt;{{ post.published_at|date:"F j, Y" }}&amp;lt;/p&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Filters format or modify data inside templates.&lt;/p&gt;

&lt;h3&gt;
  
  
  🧱 Template Inheritance (DRY Principle)
&lt;/h3&gt;

&lt;p&gt;Avoid repeating code like headers and footers using template inheritance.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;base.html&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;&amp;lt;!DOCTYPE html&amp;gt;
&amp;lt;html&amp;gt;
    &amp;lt;head&amp;gt;
        &amp;lt;title&amp;gt;{% block title %}My Site{% endblock %}&amp;lt;/title&amp;gt;
    &amp;lt;/head&amp;gt;
    &amp;lt;body&amp;gt;
        &amp;lt;header&amp;gt;&amp;lt;h1&amp;gt;My Blog&amp;lt;/h1&amp;gt;&amp;lt;/header&amp;gt;
        &amp;lt;main&amp;gt;
            {% block content %}{% endblock %}
        &amp;lt;/main&amp;gt;
        &amp;lt;footer&amp;gt;© 2025 My Blog&amp;lt;/footer&amp;gt;
    &amp;lt;/body&amp;gt;
&amp;lt;/html&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;home.html&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;{% extends 'blog/base.html' %}


{% block title %}Home Page{% endblock %}
{% block content %}
    &amp;lt;h2&amp;gt;Welcome to my blog!&amp;lt;/h2&amp;gt;
{% endblock %}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This structure keeps your HTML modular and maintainable.&lt;/p&gt;

&lt;h3&gt;
  
  
  🖼️ Static Files (CSS, JS, Images)
&lt;/h3&gt;

&lt;p&gt;Static files are assets that don't change dynamically.&lt;br&gt;
Folder structure:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;blog/
├── static/
│    └── blog/
│    ├── css/
│    │    └── style.css
│    ├── js/
│    │    └── script.js
│    └── images/
│         └── logo.png
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;settings.py Configuration&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;STATIC_URL = '/static/'
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;During development, Django automatically serves static files if DEBUG=True.&lt;/p&gt;

&lt;p&gt;Loading Static Files&lt;/p&gt;

&lt;p&gt;In your templates:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{% load static %}
&amp;lt;link rel="stylesheet" href="{% static 'blog/css/style.css' %}"&amp;gt;
&amp;lt;img src="{% static 'blog/images/logo.png' %}" alt="Logo"&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Example style.css&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;body {
    background-color: #fafafa;
    font-family: Arial, sans-serif;
    margin: 40px;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  ⚡ Best Practices
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Always use load static at the top of the templates.&lt;/li&gt;
&lt;li&gt;Keep static files organized per app (app_name/static/app_name/).&lt;/li&gt;
&lt;li&gt;Use template inheritance for reusable layouts.&lt;/li&gt;
&lt;li&gt;Avoid putting business logic inside templates.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  🏆 Summary
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Templates render dynamic HTML using context variables.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Template tags and filters add logic and formatting.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Template inheritance keeps layouts DRY.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Static files add design, interactivity, and branding.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>django</category>
      <category>webdev</category>
      <category>programming</category>
      <category>html</category>
    </item>
    <item>
      <title>🌐 Django Views – Function-Based Views (FBVs) Explained</title>
      <dc:creator>Gopal Ghate</dc:creator>
      <pubDate>Sun, 05 Oct 2025 09:45:09 +0000</pubDate>
      <link>https://dev.to/gopal_ghate_5bda01b730e45/django-views-function-based-views-fbvs-explained-article-4-42ld</link>
      <guid>https://dev.to/gopal_ghate_5bda01b730e45/django-views-function-based-views-fbvs-explained-article-4-42ld</guid>
      <description>&lt;p&gt;In Django, views are the heart of your application. They control what data is shown and how it’s displayed. A view takes a request from the user and returns a response. In this article, we’ll explore Function-Based Views (FBVs), how they work, and how to handle different request methods (GET, POST).&lt;/p&gt;

&lt;h3&gt;
  
  
  🏗 What is a View?
&lt;/h3&gt;

&lt;p&gt;A view is a Python function (or class) that receives a web request and returns a web response.&lt;/p&gt;

&lt;p&gt;Simplest view (blog/views.py):&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.http import HttpResponse


def home(request):
    return HttpResponse("Hello, Django Views!")
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then connect it in blog/urls.py:&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('', views.home, name='home'),
]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Visiting &lt;a href="http://127.0.0.1:8000/" rel="noopener noreferrer"&gt;http://127.0.0.1:8000/&lt;/a&gt; will now show: Hello, Django Views!&lt;/p&gt;

&lt;h3&gt;
  
  
  📦 Rendering Templates in Views
&lt;/h3&gt;

&lt;p&gt;Instead of plain text, we usually render HTML templates&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;def home(request):
    return render(request, 'blog/home.html', {"message": "Welcome to the Blog"})
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now in blog/templates/blog/home.html&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;h1&amp;gt;{{ message }}&amp;lt;/h1&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This will display: Welcome to the Blog&lt;/p&gt;

&lt;h3&gt;
  
  
  🔄 Handling GET and POST Requests
&lt;/h3&gt;

&lt;p&gt;Views can handle multiple request methods:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;def contact(request):
    if request.method == "POST":
        name = request.POST.get("name")
        return HttpResponse(f"Thanks for contacting us, {name}!")
    return HttpResponse("Contact Form Page")

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

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;&lt;p&gt;If it’s a GET request, it shows the form page.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;If it’s a POST request, it processes submitted data.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  🛠 Returning Different Response Types
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;1️⃣ JSON Response
&lt;/li&gt;
&lt;/ul&gt;

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


def api_data(request):
    return JsonResponse({"status": "success", "data": [1, 2, 3]})
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;2️⃣ Redirect
&lt;/li&gt;
&lt;/ul&gt;

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


def redirect_home(request):
    return redirect('home')
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  ⚡ Advantages of FBVs
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Easy to understand and quick to write.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Perfect for simple views like forms, API endpoints, or basic pages.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Direct control over request/response handling.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  ⚠️ When FBVs Become Complex
&lt;/h3&gt;

&lt;p&gt;As logic grows, FBVs can become messy with many if/else conditions. Example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
def post_handler(request):
    if request.method == "GET":
        return HttpResponse("Show posts")
    elif request.method == "POST":
        return HttpResponse("Create post")
    elif request.method == "PUT":
        return HttpResponse("Update post")
    else:
        return HttpResponse("Unsupported method")
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This works or we can create a separate functions and urls, but it gets harder to maintain. That’s why Django also provides Class-Based Views (CBVs) (coming in a later article).&lt;/p&gt;

&lt;h3&gt;
  
  
  🏆 Summary
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Views take a request and return a response.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;FBVs are functions that handle logic directly.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;You can return HTML, JSON, or redirects.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;FBVs are great for simple use cases, but can get messy for complex ones.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>django</category>
      <category>webdev</category>
      <category>programming</category>
    </item>
    <item>
      <title>🗄️ Django Models &amp; ORM Deep Dive</title>
      <dc:creator>Gopal Ghate</dc:creator>
      <pubDate>Tue, 30 Sep 2025 18:23:08 +0000</pubDate>
      <link>https://dev.to/gopal_ghate_5bda01b730e45/django-models-orm-deep-dive-article-3-3ebo</link>
      <guid>https://dev.to/gopal_ghate_5bda01b730e45/django-models-orm-deep-dive-article-3-3ebo</guid>
      <description>&lt;p&gt;In the previous article, we set up our first app and rendered a template successfully. Now, it’s time to make our app dynamic by adding a database. Django’s ORM (Object Relational Mapper) allows us to work with databases using Python classes — no SQL required!&lt;/p&gt;

&lt;p&gt;In this article, we will cover:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;What are models and the Django ORM?&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Defining fields and creating migrations.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Performing CRUD operations.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Relationships: One-to-One, One-to-Many, Many-to-Many.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Querying the database.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Quickly testing with sample data.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  🏗 What is a Django Model?
&lt;/h3&gt;

&lt;p&gt;A model is a Python class that maps to a database table. Each attribute in the class becomes a column in the table.&lt;/p&gt;

&lt;p&gt;Example (blog/models.py):&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.db import models


class Post(models.Model):
    title = models.CharField(max_length=200)
    content = models.TextField()
    published_at = models.DateTimeField(auto_now_add=True)


    def __str__(self):
        return self.title
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Django will create a table named blog_post for this model.&lt;/p&gt;

&lt;h3&gt;
  
  
  🛠 Creating Migrations
&lt;/h3&gt;

&lt;p&gt;Migrations apply model changes to the database:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;python manage.py makemigrations
python manage.py migrate
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;&lt;p&gt;makemigrations → Creates migration files.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;migrate → Applies changes to the database.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  ✍️ CRUD Operations
&lt;/h3&gt;

&lt;p&gt;** Create **&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;from blog.models import Post

Post.objects.create(title="My First Post", content="This is awesome!")
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;** Read **&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Post.objects.all() # Get all posts
Post.objects.first() # First post
Post.objects.filter(title__icontains="First")
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;** Update **&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;post = Post.objects.get(id=1)
post.title = "Updated Title"
post.save()
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;** Delete **&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;post = Post.objects.get(id=1)
post.delete()
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  🔗 Relationships Between Models
&lt;/h3&gt;

&lt;h3&gt;
  
  
  One-to-Many (ForeignKey)
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;class Comment(models.Model):
    post = models.ForeignKey(Post, related_name="comments", on_delete=models.CASCADE)
    text = models.TextField()
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Each comment belongs to one post.&lt;br&gt;
Access comments: post.comments.all()&lt;/p&gt;
&lt;h3&gt;
  
  
  One-to-One
&lt;/h3&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;from django.contrib.auth.models import User

class AuthorProfile(models.Model):
    user = models.OneToOneField(User, on_delete=models.CASCADE)
    bio = models.TextField()
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;h3&gt;
  
  
  Many-to-Many
&lt;/h3&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;class Tag(models.Model):
    name = models.CharField(max_length=50)
    posts = models.ManyToManyField(Post, related_name="tags")
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;h2&gt;
  
  
  🔍 Querying the Database
&lt;/h2&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# Exact match
Post.objects.filter(title="My First Post")


# Case-insensitive search
Post.objects.filter(title__icontains="first")


# Order results
Post.objects.order_by('-published_at')


# Access related objects
post = Post.objects.get(id=1)
comments = post.comments.all()
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;h2&gt;
  
  
  🧪 Testing with Sample Data
&lt;/h2&gt;

&lt;p&gt;You can test models directly in the Django shell:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;python manage.py shell # Make sure in the project directory
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Inside the shell :&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;from blog.models import Post

Post.objects.create(title="Sample 1", content="Hello World")
Post.objects.create(title="Sample 2", content="Learning Django ORM")


for post in Post.objects.all():
    print(post.title)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Or load fixtures from a JSON file:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;python manage.py loaddata sample_posts.json
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  🏆 Summary
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Models map Python classes to database tables.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Use migrations to apply schema changes.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;ORM provides easy CRUD operations.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Relationships (ForeignKey, OneToOne, ManyToMany) connect models.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Querysets allow powerful filtering.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Use Django shell or fixtures to test with sample data.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>django</category>
      <category>python</category>
      <category>webdev</category>
      <category>programming</category>
    </item>
    <item>
      <title>Django Project &amp; App Structure Explained</title>
      <dc:creator>Gopal Ghate</dc:creator>
      <pubDate>Sat, 27 Sep 2025 18:57:40 +0000</pubDate>
      <link>https://dev.to/gopal_ghate_5bda01b730e45/django-project-app-structure-explained-353p</link>
      <guid>https://dev.to/gopal_ghate_5bda01b730e45/django-project-app-structure-explained-353p</guid>
      <description>&lt;p&gt;Django is built with a clear separation of concerns, which makes your code easier to maintain. In this article, we’ll go deeper into projects, apps, models, views, URLs, templates, and migrations with a fully working example. By the end, you will have a running project with a correctly rendered template.&lt;/p&gt;

&lt;h3&gt;
  
  
  Django Project vs App
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Project&lt;/strong&gt; → The overall Django setup, holding settings, URL routing, and configurations.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;App&lt;/strong&gt; → A module inside your project designed for a specific purpose. You can have multiple apps inside one project.&lt;br&gt;
For example&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;mysite/ # Project
├── manage.py
├── mysite/ # Project settings folder
└── blog/ # App folder
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You might have multiple apps like users, payments, or products under the same project.&lt;/p&gt;

&lt;h3&gt;
  
  
  Project Structure Explained
&lt;/h3&gt;

&lt;p&gt;When you run django-admin startproject mysite, you get:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;mysite/
├── manage.py
└── mysite/
├── __init__.py
├── asgi.py
├── settings.py
├── urls.py
└── wsgi.py
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Let’s break these files down:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;manage.py&lt;/strong&gt; → Command-line tool to run server, create apps, apply migrations, open Django shell, etc.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;settings.py&lt;/strong&gt; → Central configuration (DB, installed apps, middleware, security keys).&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;urls.py&lt;/strong&gt; → Main URL router; maps paths to views.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;wsgi.py / asgi.py&lt;/strong&gt; → Entry point for deployment (used by production servers).&lt;/p&gt;

&lt;h3&gt;
  
  
  Creating Your First App
&lt;/h3&gt;

&lt;p&gt;Run :&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;python manage.py startapp blog #(blog -&amp;gt; app name, you can add your app name here)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This creates following folder structure&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;blog/
├── admin.py
├── apps.py
├── migrations/
├── models.py
├── tests.py
├── views.py
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Add newly created app to INSTALLED_APPS in settings.py:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'blog', # add your app name here.
]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Adding Views &amp;amp; URLs
&lt;/h3&gt;

&lt;p&gt;In blog/views.py&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 render

def home(request):
return render(request, 'blog/home.html')
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Create blog/urls.py&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('', views.home, name='home'),
]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Include app urls in project urls (mysite/urls)&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.contrib import admin
from django.urls import path, include


urlpatterns = [
path('admin/', admin.site.urls),
path('', include('blog.urls')),
]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Templates Setup
&lt;/h3&gt;

&lt;p&gt;Folder Structure (App-Level Templates)&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;blog/
├── templates/
  │ └── blog/
      │ └── home.html
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;home.html example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;!DOCTYPE html&amp;gt;
&amp;lt;html&amp;gt;
&amp;lt;head&amp;gt;
&amp;lt;title&amp;gt;My First Django Page&amp;lt;/title&amp;gt;
&amp;lt;/head&amp;gt;
&amp;lt;body&amp;gt;
&amp;lt;h1&amp;gt;Welcome to My Blog!&amp;lt;/h1&amp;gt;
&amp;lt;p&amp;gt;This page is powered by Django templates.&amp;lt;/p&amp;gt;
&amp;lt;/body&amp;gt;
&amp;lt;/html&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  settings.py Configuration:
&lt;/h2&gt;

&lt;p&gt;Make sure APP_DIRS=True:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [], # leave empty for app-level templates
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
           'django.template.context_processors.debug',
           'django.template.context_processors.request',
           'django.contrib.auth.context_processors.auth',
           'django.contrib.messages.context_processors.messages',
        ],
     },
  },
]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now render(request, 'blog/home.html') will find the template&lt;/p&gt;

&lt;h2&gt;
  
  
  Migrations &amp;amp; Database
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;python manage.py migrate
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Run the server
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;python manage.py runserver
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Summary
&lt;/h2&gt;

&lt;p&gt;In this article, we:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Understood the difference between projects and apps.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Learned about project files and what they do.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Created an app and added views, urls, and templates.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Correctly configured settings.py and rendered a template.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Ran migrations and started the server.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>django</category>
      <category>webdev</category>
      <category>python</category>
      <category>programming</category>
    </item>
    <item>
      <title>🚀 Getting Started with Django – A Beginner-Friendly Guide</title>
      <dc:creator>Gopal Ghate</dc:creator>
      <pubDate>Thu, 25 Sep 2025 17:03:39 +0000</pubDate>
      <link>https://dev.to/gopal_ghate_5bda01b730e45/getting-started-with-django-a-beginner-friendly-guide-4j4a</link>
      <guid>https://dev.to/gopal_ghate_5bda01b730e45/getting-started-with-django-a-beginner-friendly-guide-4j4a</guid>
      <description>&lt;p&gt;If you’ve ever wondered how to build powerful, scalable web applications without reinventing the wheel, Django is your best friend. Django is a high-level Python web framework that allows you to build web apps quickly, securely, and with less code. In this article, we’ll walk through the basics of Django, its project structure, and get you ready to write your first app.&lt;/p&gt;

&lt;h2&gt;
  
  
  🎯 Why Django?
&lt;/h2&gt;

&lt;p&gt;Django is popular because it follows the "batteries-included" philosophy, meaning it comes with everything you need to build web apps:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;✅ &lt;strong&gt;ORM (Object-Relational Mapper)&lt;/strong&gt;: Work with databases using Python instead of writing SQL.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;✅ &lt;strong&gt;Admin Panel&lt;/strong&gt;: Auto-generated backend to manage your data.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;✅ &lt;strong&gt;Security&lt;/strong&gt;: Protection against common vulnerabilities (SQL injection, CSRF, XSS).&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;✅ &lt;strong&gt;Scalability&lt;/strong&gt;: Used by Instagram, Pinterest, and Disqus.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;In short — Django makes web development fast, secure, and fun.&lt;/p&gt;

&lt;h2&gt;
  
  
  🛠 Installing Django
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;python3 -m venv venv # creates virtual environment for project

source venv/bin/activate # activate virtual environment

pip install django # installing django

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

&lt;/div&gt;



&lt;h2&gt;
  
  
  Check if it’s installed:
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;django-admin --version # Checking django version
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  🏗 Creating Your First Project
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;django-admin startproject mysite 
cd mysite

# your folder structure should look like this.
mysite/
├── manage.py
├── mysite/
│   ├── __init__.py
│   ├── settings.py
│   ├── urls.py
│   ├── asgi.py
│   └── wsgi.py

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

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;1️⃣ manage.py – Your Project’s Remote Control
This file is used to run commands related to your project.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;python manage.py runserver     # Start development server
python manage.py startapp blog # Create a new app
python manage.py makemigrations # Look at models and creates migration files that describe those changes.
python manage.py migrate       # Apply database changes

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

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;2️⃣ settings.py
This file contains all the configuration settings:&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Database setup: Which database you’re using (default: SQLite).&lt;/p&gt;

&lt;p&gt;Installed apps: Which Django apps are active.&lt;/p&gt;

&lt;p&gt;Security keys: Secret key for cryptography, allowed hosts.&lt;/p&gt;

&lt;p&gt;Static files: CSS, JavaScript, images.&lt;/p&gt;

&lt;p&gt;You can think of it as your project’s control center.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;3️⃣ urls.py - routing
This file decides which view handles which URL.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;from django.urls import path
from django.http import HttpResponse

def home(request):
    return HttpResponse("Welcome Home!")

urlpatterns = [
    path('', home),
    path('about/', lambda r: HttpResponse("About Page")),
]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;4️⃣ wsgi.py &amp;amp; asgi.py – The Gatekeepers&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;These files allow your project to talk to web servers in production:&lt;/p&gt;

&lt;p&gt;WSGI: For traditional synchronous servers like Gunicorn.&lt;/p&gt;

&lt;p&gt;ASGI: For asynchronous servers like Daphne, great for WebSockets.&lt;/p&gt;

&lt;p&gt;You rarely modify these files, but they’re essential for deployment.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;▶ Running the Development Server
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;python manage.py runserver
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Open your browser at &lt;a href="http://127.0.0.1:8000/" rel="noopener noreferrer"&gt;http://127.0.0.1:8000/&lt;/a&gt;. 🎉 You just ran your first Django project!&lt;/p&gt;

&lt;h2&gt;
  
  
  📌 Key Takeaways
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Django is a full-stack framework with built-in tools.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Your project structure has specific files for config, routing, and deployment.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;manage.py is your main command-line tool.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;urls.py maps URLs to views.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

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