<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Ankit Poudel on Medium]]></title>
        <description><![CDATA[Stories by Ankit Poudel on Medium]]></description>
        <link>https://medium.com/@ankitpoudel_?source=rss-afc564ef1b6a------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*zwK8_iLx3vkdjUZ2y_CMYA@2x.jpeg</url>
            <title>Stories by Ankit Poudel on Medium</title>
            <link>https://medium.com/@ankitpoudel_?source=rss-afc564ef1b6a------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 30 Nov 2026 09:42:43 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@ankitpoudel_/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[What Makes AI Agentic? A Deep Dive into Its Core Characteristics]]></title>
            <link>https://medium.com/@ankitpoudel_/what-makes-ai-agentic-a-deep-dive-into-its-core-characteristics-4b5bad67878c?source=rss-afc564ef1b6a------2</link>
            <guid isPermaLink="false">https://medium.com/p/4b5bad67878c</guid>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[llm]]></category>
            <category><![CDATA[agentic-ai]]></category>
            <category><![CDATA[ai-agent]]></category>
            <dc:creator><![CDATA[Ankit Poudel]]></dc:creator>
            <pubDate>Sun, 12 Apr 2026 14:06:38 GMT</pubDate>
            <atom:updated>2026-04-12T14:06:38.143Z</atom:updated>
            <content:encoded><![CDATA[<p>Agentic AI is a type of AI that can take up a task or goal from a user and then work toward completing it on its own, with minimal human guidance. It plans, takes action, adapts to changes and seeks help only when necessary. Unlike generative AI-based applications, which are reactive, agentic AI-based applications are proactive.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YSEKZM_bRl1_aCBH02kR6g.png" /></figure><h3>Key Characteristics of Agentic AI</h3><p>The key characteristics of Agentic AI are as follows:</p><h3>1) Autonomous</h3><p>Autonomy refers to the AI system’s ability to make decisions and take actions on its own to achieve a given goal, without needing step-by-step human instructions.</p><p>Agentic AI systems are autonomous across multiple facets, such as execution, decision-making, and tool usage.</p><p>The autonomy of an agentic AI system can be controlled using techniques like guardrails, policies, permission scoping, Human-in-the-Loop (HITL), override controls and so on.</p><p>That said, autonomy can also be dangerous if not properly constrained.</p><h3>2) Goal-Oriented</h3><p>Being goal-oriented means that the AI system operates with a persistent objective in mind and continuously directs its actions toward achieving that objective, rather than simply responding to isolated prompts.</p><p>Goals can come with constraints and act as a compass for autonomy. The goal of an agentic AI system can also be altered dynamically based on new requirements or feedback.</p><h3>3) Planning</h3><p>This is one of the most important features of Agentic AI.</p><p>Planning is the agent’s ability to break down a high-level goal into a structured sequence of actions or subgoals and decide the best path to achieve the desired outcome.</p><p>Agentic systems typically execute planning in three steps:</p><ol><li>First, they generate multiple candidate plans.</li><li>Second, they evaluate each plan.</li><li>Third and finally, they select the best plan with the help of Human-in-the-Loop (HITL) feedback or a pre-programmed policy.</li></ol><h3>4) Reasoning</h3><p>Reasoning is the cognitive process through which an agentic AI system interprets information, draws conclusions and makes decisions both while planning ahead and while executing actions in real time.</p><p>Reasoning capability in agentic systems is required in both the planning and execution stages.</p><h3>5) Adaptability</h3><p>Adaptability is the agent’s ability to modify its plans, strategies, or actions in response to unexpected conditions, all while staying aligned with the goal.</p><p>The agent should be able to react to changes in the environment it is operating in and should handle failures, external feedback, changing goals and similar disruptions gracefully.</p><h3>6) Context Awareness</h3><p>Context awareness is the agent’s ability to understand, retain, and utilize relevant information from ongoing tasks, past interactions, user preferences, and environmental cues to make better decisions throughout a multi-step process.</p><p>The types of context an agentic AI can have include the original goal, progress so far and interaction history, tool responses, user-specific preferences, guardrails/policy constraints and so on.</p><p>Context awareness is typically implemented through memory in Agentic AI systems. This memory can be:</p><ul><li>Short-term memory which stores information related to the current session</li><li>Long-term memory which stores information related to historical interactions, user preferences, and persistent knowledge across sessions</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4b5bad67878c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Understanding In-Context Learning with Examples]]></title>
            <link>https://python.plainenglish.io/understanding-in-context-learning-with-examples-85f0fb4d8481?source=rss-afc564ef1b6a------2</link>
            <guid isPermaLink="false">https://medium.com/p/85f0fb4d8481</guid>
            <category><![CDATA[llm]]></category>
            <category><![CDATA[in-context-learning]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[generative-ai]]></category>
            <category><![CDATA[rags]]></category>
            <dc:creator><![CDATA[Ankit Poudel]]></dc:creator>
            <pubDate>Fri, 03 Apr 2026 19:00:24 GMT</pubDate>
            <atom:updated>2026-04-03T19:17:31.734Z</atom:updated>
            <content:encoded><![CDATA[<p>In-Context Learning (ICL) is a core capability of Large Language Models (LLMs) like GPT-3/4, Claude &amp; Llama, where the model learns to solve a task purely by seeing examples in the prompt, without updating its weights.</p><p>In simpler words, you show the model a few examples, and it figures out the pattern on the fly.</p><p>The key idea behind ICL is:</p><blockquote><em>show pattern → model continues pattern</em></blockquote><p>The learning in ICL happens inside the current prompt context. The model uses instructions, examples, formatting patterns, previous chat history and more to infer what task it should perform right now. This is where prompt design plays a very significant role.</p><p>The model doesn’t require any additional pre-training, fine-tuning or gradient updates, it simply learns from the context window.</p><figure><img alt="Understanding In-Context Learning with Examples" src="https://cdn-images-1.medium.com/max/1024/1*U4jY7EqV6KQhDWH4AT1Cgg.png" /></figure><p>In-Context Learning is considered an emergent property of LLMs, meaning this behavior was not explicitly programmed into the models or even fully expected by researchers. Instead, it began to appear naturally once language models reached a certain scale and level of complexity.</p><p>Research shows that ICL becomes significantly stronger as models grow larger, because larger models are better at inferring new label mappings, reasoning patterns, and task structures directly from examples.</p><p>This phenomenon was first systematically observed in the landmark paper <a href="https://arxiv.org/abs/2005.14165">“Language Models are Few-Shot Learners” (Brown et al., 2020)</a>, where the authors demonstrated that extremely large language models, like GPT-3, could perform a wide variety of NLP tasks directly from examples in the prompt, without any fine-tuning. Their work formalized the concept of few-shot and in-context learning, providing the foundation for modern prompt engineering.</p><p>ICL is one of the most useful abilities in modern AI. Below are a few useful examples to help you understand it better.</p><h4>Example 1: Sentiment Classification</h4><pre>#Input <br>Below are examples of texts labeled with their sentiment. <br>Use these example to determine the sentiment of the final text.<br><br>Review: This phone is amazing<br>Sentiment: Positive<br><br>Review: Worst laptop I ever bought<br>Sentiment: Negative<br><br>Review: Camera quality is very poor. <br>Sentiment: Negative<br><br>Review: Battery life is fantastic<br>Sentiment:</pre><pre>#Output<br>Positive</pre><p>Here, the model learns sentiment analysis through examples and is able to categorize reviews as positive or negative.</p><h4>Example 2: Writing Style Mimicking</h4><pre>#Input<br>Write in style:<br>Example: The server crashed due to an unhandled null pointer.<br><br>Now explain:<br>Redis cache miss issue</pre><pre>#Output<br>The Redis lookup failed because the requested key was absent from the cache layer.</pre><p>Here, the model is able to mimic the writing style from an example.</p><h4>Example 3: Hidden Pattern Classification</h4><pre>#Input<br>Dog -&gt; Animal<br>Rose -&gt; Plant<br>Carrot -&gt; Plant<br>Cat -&gt;</pre><pre>#Output<br>Animal</pre><p>Here, the model is able to infer the hidden task, which is to classify inputs into biological categories.</p><h4>Example 4: Structured Data Extraction</h4><pre>#Input:<br>Text: Ankit bought a MacBook for $1200<br>Output: {&quot;name&quot;:&quot;Ankit&quot;,&quot;item&quot;:&quot;MacBook&quot;,&quot;price&quot;:1200}<br><br>Text: Sara purchased iPhone for $900<br>Output:</pre><pre>#Output<br>{&quot;name&quot;:&quot;Sara&quot;,&quot;item&quot;:&quot;iPhone&quot;,&quot;price&quot;:900}</pre><p>Here, the model is able to extract key information from text into a JSON object. This is highly useful in APIs and RAG pipelines.</p><h4>Example 5: Reasoning Pattern Learning</h4><pre>#Input <br>Q: If 2 pens cost $4, what is 1 pen?<br>A: Divide 4 by 2 = 2 dollars<br><br>Q: If 5 apples cost $10, what is 1 apple?<br>A:</pre><pre>#Output<br>Divide 10 by 5 = 2 dollars</pre><p>Here, the model is using a stronger form of ICL known as chain-of-thought reasoning and is able to copy the reasoning format from examples.</p><h4>Example 6: Context Learning in RAG</h4><pre>Context:<br>Django ORM uses models.Model.<br>FastAPI uses Pydantic schemas.<br><br>Question: Which framework uses Pydantic?</pre><pre>FastAPI uses Pydantic schemas.</pre><p>Here, the model is learning from retrieved context inside the prompt. This is widely used in RAG-based systems.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=85f0fb4d8481" width="1" height="1" alt=""><hr><p><a href="https://python.plainenglish.io/understanding-in-context-learning-with-examples-85f0fb4d8481">Understanding In-Context Learning with Examples</a> was originally published in <a href="https://python.plainenglish.io/">Python in Plain English</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[LangChain 101: How It Works Under the Hood]]></title>
            <link>https://medium.com/@ankitpoudel_/langchain-101-how-it-works-under-the-hood-8a3b2347c439?source=rss-afc564ef1b6a------2</link>
            <guid isPermaLink="false">https://medium.com/p/8a3b2347c439</guid>
            <category><![CDATA[agents]]></category>
            <category><![CDATA[vector-database]]></category>
            <category><![CDATA[langchain]]></category>
            <category><![CDATA[llm]]></category>
            <category><![CDATA[chatbots]]></category>
            <dc:creator><![CDATA[Ankit Poudel]]></dc:creator>
            <pubDate>Sun, 29 Mar 2026 19:09:50 GMT</pubDate>
            <atom:updated>2026-04-02T15:42:56.486Z</atom:updated>
            <content:encoded><![CDATA[<p>LangChain is an open-source framework for building applications powered by LLMs. It helps orchestrate the various components required in such systems and simplifies development through the concept of chains, which structures and manages the flow of data between steps.</p><p>Another key advantage of LangChain is that it is model-agnostic meaning it provides a standardized interface that allows developers to easily integrate, switch between or experiment with different LLMs helping avoid vendor lock-in.</p><p>To effectively build LLM-powered applications, it’s important to understand how LangChain works under the hood. Following are six components that make up LangChain.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*a3mZUPAVZVe3dnzRhgGrzg.png" /></figure><ol><li>Models</li></ol><p>In LangChain, models are the core interfaces used to interact with various language models and embedding models. They provide a standardized way to connect with different LLM providers such as OpenAI, Anthropic or Google so you can switch between them with minimal code changes.</p><p>This abstraction makes your application more flexible and prevents vendor lock-in, since the underlying provider can be swapped without rewriting your logic.</p><p>In LangChain, models are broadly divided into two types:</p><ul><li><strong>Language Models: </strong>used for generating and understanding text (e.g., answering questions, summarizing, or chatting).</li><li><strong>Embedding Models: </strong>used to convert text into numerical vectors, enabling tasks like semantic search, similarity comparison, and retrieval.</li></ul><p>2. Prompts</p><p>Prompts are the inputs we provide to LLMs, and they play a critical role in shaping the model’s output. Even small changes in wording can lead to significantly different responses.</p><p>For example:</p><p><em>&gt; Explain X in an academic tone.<br>&gt; Explain X in a fun tone.</em></p><p>Here, changing just one word “academic” to “fun” produces entirely different styles of answers. This highlights how sensitive LLMs are to prompt design.</p><p>LangChain enables developers to create powerful prompting strategies such as dynamic &amp; reusable prompts, role-based prompts and few-shot prompting.</p><p>3. Chains</p><p>Chains are one of the most important components in LangChain. They allow you to build and streamline pipelines for your LLM-powered applications by defining how data flows between different steps.</p><p>When a chain is executed, it automatically passes the output of one step as the input to the next, handling much of the orchestration behind the scenes. This makes it easier to build structured workflows without manually wiring each component together.</p><p>While chains are often used for simple sequential pipelines, they can also support more advanced workflows such as parallel execution and conditional logic enabling the creation of complex, dynamic application pipelines.</p><p>4. Indexes</p><p>Indexes connect your application to external knowledge sources such as PDFs, websites, or databases. Foundational models are trained on broad, general data, so they often lack access to specific or private information, for example, “What is the leave policy at XYZ company?”</p><p>This limitation can be addressed by integrating LLMs with external knowledge sources. In this setup, when an LLM is paired with a knowledge base such as XYZ company’s internal rulebook containing its leave policy, it can retrieve the relevant information and provide an accurate, context-aware answer.</p><p>Indexes include document loader, text splitter, vector store and retrievers.</p><p>5. Memory</p><p>LLM API calls are stateless i.e. each request is independent and has no memory of previous interactions. This becomes a limitation when building applications like conversational chatbots, where maintaining context across multiple turns is essential.</p><p>To address this, LangChain provides a memory component that stores and manages past interactions, allowing the model to generate more coherent and context-aware responses.</p><p>Some common types of memory in LangChain include:</p><ul><li><strong>ConversationBufferMemory: </strong>Stores the entire conversation history and sends it with each request.</li><li><strong>ConversationBufferWindowMemory: </strong>Keeps only the most recent <em>N</em> interactions, helping control context size.</li><li><strong>Summarizer-Based Memory: </strong>Compresses past conversations into a concise summary to retain context efficiently.</li><li><strong>Custom Memory: </strong>Allows you to design your own memory logic tailored to specific application needs.</li></ul><p>6. Agents</p><p>So far, one of the most popular use cases of LLMs has been chatbot applications like ChatGPT. But what if these systems could do more than just respond to queries what if they could take actions on your behalf? That’s where AI agents come in.</p><p>Imagine a travel assistant chatbot. Instead of just suggesting destinations, it could analyze hotel prices over time, identify the cheapest dates, check your availability and even book the hotel for you. This shift from answering questions to completing tasks is the core idea behind agents.</p><p>In essence, AI agents are chatbots with “superpowers.” They extend beyond simple conversation by incorporating:</p><ul><li><strong>Reasoning capabilities: </strong>allowing them to think through problems, make decisions and plan multi-step actions.</li><li><strong>Access to tools: </strong>enabling them to interact with external systems (APIs, databases, booking services, etc.) to perform real-world tasks.</li></ul><p>This combination allows agents to act autonomously and handle complex workflows, making them far more powerful than traditional chatbots.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8a3b2347c439" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Build a Simple REST API with Django REST Framework: A Step-by-Step Guide]]></title>
            <link>https://medium.com/@ankitpoudel_/build-a-simple-rest-api-with-django-rest-framework-a-step-by-step-guide-bc996201d248?source=rss-afc564ef1b6a------2</link>
            <guid isPermaLink="false">https://medium.com/p/bc996201d248</guid>
            <category><![CDATA[django-rest-framework]]></category>
            <category><![CDATA[django]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[api-development]]></category>
            <dc:creator><![CDATA[Ankit Poudel]]></dc:creator>
            <pubDate>Sun, 27 Jul 2025 17:08:27 GMT</pubDate>
            <atom:updated>2025-07-27T17:08:27.451Z</atom:updated>
            <content:encoded><![CDATA[<p>Django Rest Framework (DRF) is a powerful library built on top of Django that makes it easy for you to create RESTful APIs utilizing Django’s existing feature sets.</p><p>If you have experience working with Django or similar framework, it is pretty easy for you to get up and running. In this article, I will walk you through your first DRF project. We’ll build a simple Book API that lets us list, add, view, update and delete books.</p><p>If you want to jump directly to the code for this project, GitHub link for it is provided at the end.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*RgSN_3XUNkbU1ZVeXci7_w.jpeg" /></figure><h3><strong>Step-by-Step Guide to Django REST Framework: Build a Book API</strong></h3><h4>1. Setup environment</h4><p>We will get started by creating a virtual environment. This will help us avoid potential dependency version conflicts in the future.</p><pre>python -m venv venv<br>venv\Scripts\activate</pre><h4>2. Install dependencies</h4><p>For this project, we’ll install only Django and Django REST Framework (DRF). Optionally, you can also install drf-yasg to automatically generate Swagger API documentation.</p><pre>pip install django djangorestframework<br>pip install drf-yasg </pre><h4>3. Start Django project and app</h4><pre>django-admin startproject books<br>cd books<br>django-admin startapp api</pre><p>After running these command your project directory will look something like this:</p><pre>books/<br>├── api/<br>│   ├── __init__.py<br>│   ├── admin.py<br>│   ├── apps.py<br>│   ├── models.py<br>│   ├── tests.py<br>│   └── views.py<br>├── books/<br>│   ├── __init__.py<br>│   ├── asgi.py<br>│   ├── settings.py<br>│   ├── urls.py<br>│   └── wsgi.py<br>├── manage.py</pre><h4>4. Add app &amp; DRF onto INSTALLED_APPS in settings.py</h4><pre># books/books/settings.py<br><br>INSTALLED_APPS = [<br>    ...<br>    &#39;rest_framework&#39;,<br>    &#39;api&#39;,<br>    &#39;drf_yasg&#39;,<br>]</pre><h4>5. Create Book Model</h4><p>For this project, I’ve created a simple Book model with three fields: title, author, and published_date.</p><pre># books/api/models.py<br><br>from django.db import models<br><br>class Book(models.Model):<br>    title = models.CharField(max_length=500)<br>    author = models.CharField(max_length=255)<br>    published_date = models.DateField()<br>    <br>    def __str__(self):<br>        return f&#39;{self.title} - {self.author}&#39;</pre><h4>6. Register Book model in admin.py</h4><pre># books/api/admin.py<br><br>from django.contrib import admin<br>from .models import Book<br><br>admin.site.register(Book)</pre><h4>7. Create admin super user and add dummy user data for testing</h4><p>To access the Django admin panel and easily manage your data during development, create a superuser account.</p><pre>python manage.py createsuperuser</pre><p>Follow the prompts to enter a username, email, and password. Once created, run the server.</p><p>Then, go to http://localhost:8000/admin/ log in with your superuser credentials and manually add some dummy Book data for testing.</p><p>Alternatively, you can also add dummy data through python shell.</p><pre>python manage.py shell</pre><pre>from api.models import Book<br>Book.objects.create(title=&quot;Bad Book&quot;, author=&quot;Not Ankit&quot;, published_date=&quot;2025-01-01&quot;)<br>Book.objects.create(title=&quot;Good Book&quot;, author=&quot;Ankit&quot;, published_date=&quot;2025-01-01&quot;)</pre><h4>8. Create Serializer</h4><p>Now, onto one of the most important and fun parts of working with DRF: Serializers.</p><p>Serializers are a core concept in DRF and are essential for building APIs. They are responsible for:</p><ul><li>Packaging data (when sending it to the client)</li><li>Unpackaging data (when receiving it from the client)</li></ul><p>In simple terms, serializers handle:</p><ul><li><strong>Serialization</strong>: Convert Django model → JSON (for sending data to the client).</li><li><strong>Deserialization</strong>: Convert JSON → Python datatype → Django model instance (for receiving data from the client)</li></ul><p>There are essentially two ways of defining serializers in DRF:</p><ol><li>Manual serializers (serializers.Serializer)</li></ol><p>Use this when:</p><ul><li>You’re working with non-model data</li><li>You want complete control over how data is handled</li><li>You’re learning how DRF works under the hood</li></ul><pre># books/api/serializers.py<br><br>from rest_framework import serializers<br>from .models import Book<br><br>class BookSerializer(serializers.Serializer):<br>    title = serializers.CharField(max_length=500)<br>    author = serializers.CharField(max_length=255)<br>    published_date = serializers.DateField()<br>    <br>    def create(self, validated_data):<br>        return Book.objects.create(**validated_data)<br>    <br>    def update(self, instance, validated_data):<br>        instance.title = validated_data.get(&#39;title&#39;, instance.title)<br>        instance.author = validated_data.get(&#39;author&#39;, instance.author)<br>        instance.published_date = validated_data.get(&#39;published_date&#39;, instance.published_date)<br>        instance.save()<br>        return instance</pre><p>DRF provides many fields that map to Django model fields. In our example:</p><ul><li>CharField → for CharField</li><li>DateField → for DateField</li></ul><p>When using manual serializers, you must explicitly define:</p><ul><li>create(validated_data): What to do when a new object is created ( POST)</li><li>update(instance, validated_data): How to update an existing object (PUT or PATCH)</li></ul><p>These methods are required because DRF doesn’t know how to save the data unless you tell it how.</p><p>2. Automatic serializers (serializers.ModelSerializer)</p><p>Use this when:</p><ul><li>You’re working directly with Django models</li><li>You want DRF to do most of the heavy lifting automatically</li><li>You don’t need much custom behavior</li></ul><pre># books/api/serializers.py<br><br>class BookSerializer(serializers.ModelSerializer):<br>    class Meta:<br>        model = Book<br>        fields = [&#39;id&#39;, &#39;title&#39;, &#39;author&#39;, &#39;published&#39;]</pre><p>With ModelSerializer, DRF automatically:</p><ul><li>Maps model fields to serializer fields</li><li>Generates create() and update() methods under the hood</li><li>Reduces boilerplate code significantly</li></ul><p><strong>Which One Should You Use?</strong></p><p>Both approaches are valid and work well for our use case.</p><p>However, when you’re just getting started, I recommend using manual serializers to understand how data is transformed and saved under the hood. Once you’re comfortable, ModelSerializer becomes the go-to choice for rapid development.</p><h4>9. Create API Views</h4><p>Now that we’ve built our serializer, it’s time to actually create the views that will handle the HTTP requests.</p><p>In DRF, views are responsible for defining the behavior of our API; what happens when a user sends a GET, POST, PUT, or DELETE request.</p><p>For each view we will be using @api_view decorator to convert Django views into REST-compliant ones.</p><pre>from rest_framework.decorators import api_view<br>from rest_framework.response import Response<br>from rest_framework import status<br><br>from .models import Book<br>from .serializers import BookSerializer<br><br><br>@api_view([&#39;GET&#39;, &#39;POST&#39;])<br>def book_list(request):<br>    if request.method == &#39;GET&#39;:<br>        books = Book.objects.all()<br>        serializer = BookSerializer(books, many=True)<br>        return Response(serializer.data)<br>    <br>    elif request.method == &#39;POST&#39;:<br>        serializer = BookSerializer(data=request.data)<br>        if serializer.is_valid():<br>            serializer.save()<br>            return Response(serializer.data, status=status.HTTP_201_CREATED)<br>        return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)</pre><p>The view presented above handles GET and POST route indicated by the decorator @api_view([&#39;GET&#39;, &#39;POST&#39;]) in the top of the view.</p><p>Notice that each time any type of data leaves our view, it’s passed through the BookSerializer. This ensures two things:</p><ul><li>Output is structured in clean &amp; valid JSON format</li><li>Input is validated before being saved to the database</li></ul><p>Similarly, we also define a view to handle other remaning operations.</p><pre>@api_view([&#39;GET&#39;, &#39;PUT&#39;, &#39;PATCH&#39;, &#39;DELETE&#39;])<br>def book_detail(request, id):<br>    book = get_object_or_404(Book, pk=id)<br>    <br>    if request.method == &#39;GET&#39;:<br>        serializer = BookSerializer(book)<br>        return Response(serializer.data)<br>    <br>    elif request.method == &#39;PUT&#39;:<br>        serializer = BookSerializer(book, data=request.data)<br>        if serializer.is_valid():<br>            serializer.save()<br>            return Response(serializer.data)<br>        return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)<br>    <br>    elif request.method == &#39;PATCH&#39;:<br>        serializer = BookSerializer(book, data=request.data, partial=True)<br>        if serializer.is_valid():<br>            serializer.save()<br>            return Response(serializer.data)<br>        return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)<br>    <br>    elif request.method == &#39;DELETE&#39;:<br>        book.delete()<br>        return Response(status=status.HTTP_204_NO_CONTENT)</pre><h4>10. Set up urls.py and map API onto relevant routes</h4><p>Once views are ready, we need to expose them via URLs. This is how the API becomes accessible to clients like frontend apps, Postman or mobile apps.</p><p>In project level include the app’s API URLs. By including path(&#39;books/&#39;, include(&#39;api.urls&#39;)) in urlspatterns list you’ll be able to route all book-related APIs to route with books/ prefix.</p><pre># In books/books/urls.py<br><br>from django.contrib import admin<br>from django.urls import path, include<br><br>urlpatterns = [<br>    path(&#39;admin&#39;, admin.site.urls),<br>    path(&#39;books&#39;, include(&#39;api.urls&#39;)),<br>]</pre><p>In app-level urls.py we include all the endpoints through which clients can interact with our APIs.</p><pre># In books/api/urls.py<br><br>from django.urls import path<br>from . import views<br><br>urlpatterns = [<br>    path(&#39;&#39;, views.book_list),             <br>    path(&#39;/&lt;int:id&gt;&#39;, views.book_detail),  <br>]</pre><p>Now, let’s break down each endpoint present in the urls.py.</p><p><strong><em>books/</em></strong></p><p>This endpoint is connected to the book_list view. It handles two request types:</p><ul><li>GET: Fetch and return a list of all books in the database</li><li>POST: Receive JSON data and create a new book entry in the database</li></ul><p><strong><em>books/&lt;int:id&gt;/</em></strong></p><p>This endpoint is connected to the book_detail view. It handles four request types</p><ul><li>GET: Retrieve details of a specific book by its ID</li><li>PUT: Replace the entire book data with new data</li><li>PATCH: Partially update the book</li><li>DELETE: Remove the book from the database</li></ul><p>Now, let’s all recap how each views, serializers and urls are connected:</p><ul><li><strong>Views</strong>: Define what to do with each request (book_list, book_detail)</li><li><strong>Serializers</strong>: Handle data validation and transformation (Python ↔ JSON)</li><li><strong>URLs</strong>: Route incoming HTTP requests to the correct view</li></ul><blockquote>Revisit the view logic in Point 8 to better understand how each endpoint behaves when different request methods (GET, POST, PUT, DELETE) are used.</blockquote><h4>11. Setup auto API docs with Swagger (Optional)</h4><p>DRF supports automatic documentation generation and <strong>Swagger (via drf-yasg)</strong> is one of the most popular tools for this.</p><p>We have already installed the required package i.e.drf-yasg. So, to generate the auto docs simply add this to the root urls.py file.</p><pre># books/books/urls.py <br><br>from django.contrib import admin<br>from django.urls import path, include<br>from rest_framework import permissions<br>from drf_yasg.views import get_schema_view<br>from drf_yasg import openapi<br><br>schema_view = get_schema_view(<br>     openapi.Info(<br>        title=&quot;Book API&quot;,<br>        default_version=&#39;v1&#39;,<br>        description=&quot;Simple Book API built using Django REST Framework&quot;,<br>    ),<br>    public=True, <br>    permission_classes=[permissions.AllowAny],<br>)<br><br>urlpatterns = [<br>    path(&#39;admin/&#39;, admin.site.urls),<br>    path(&#39;books/&#39;, include(&#39;api.urls&#39;)),<br>    path(&#39;&#39;, schema_view.with_ui(&#39;swagger&#39;, cache_timeout=0), name=&#39;schema-swagger-ui&#39;),<br>]</pre><p>After adding the necessary schema and route for Swagger docs in urlspatterns list, you will be able to access the documentation in the base route itself at<a href="http://127.0.0.1:8000/swagger/">http://127.0.0.1:8000</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PAbEJoScwlnlFp1tKFdaiw.png" /></figure><h4>12. Test the API using Swagger or Postman</h4><p>Once your API routes are set up, it’s time to test everything and make sure it works as expected. We will simply use auto-generated Swagger documentation we set up earlier (in Point 9).</p><p>For each endpoint, make sure you provide valid input where required.</p><p>And since we haven’t added any authentication yet, you can access all endpoints without logging in making it easy to test freely during development. In real production environment we will be protecting our APIs with access tokens or session auth.</p><p>Here are some examples to try for testing our APIs:</p><ul><li>GET /books/ → Should return a list of all books</li><li>POST /books/ → Add a new book (make sure to include title, author, published date)</li><li>GET /books/1/ → Get details of the book with ID 1</li><li>PUT /books/1/ → Update that book&#39;s information</li><li>DELETE /books/1/ → Remove the book</li></ul><h3>Conclusion</h3><p>And that’s it, you’ve successfully built a basic API using DRF. You learned how to:</p><ul><li>Create models and serializers</li><li>Set up URL routes</li><li>Write views to handle API logic</li><li>Test your API using Swagger</li></ul><p>With this solid foundation, you’re now ready to explore more advanced features in DRF such as ViewSets, pagination, filtering, and authentication.</p><p>That’s all from me, now it’s your turn to experiment, explore and take things further! Ankit out.</p><p>🔗 <a href="https://github.com/ankman007/book-api">GitHub Repo Link</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=bc996201d248" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[17 Essential Steps to Prepare Your Django App for Production]]></title>
            <link>https://python.plainenglish.io/17-essential-steps-to-prepare-your-django-app-for-production-a2e7a8c49a8f?source=rss-afc564ef1b6a------2</link>
            <guid isPermaLink="false">https://medium.com/p/a2e7a8c49a8f</guid>
            <category><![CDATA[python]]></category>
            <category><![CDATA[django-admin]]></category>
            <category><![CDATA[python3]]></category>
            <category><![CDATA[django]]></category>
            <category><![CDATA[django-rest-framework]]></category>
            <dc:creator><![CDATA[Ankit Poudel]]></dc:creator>
            <pubDate>Sat, 26 Jul 2025 08:48:13 GMT</pubDate>
            <atom:updated>2025-07-26T08:48:13.687Z</atom:updated>
            <content:encoded><![CDATA[<p>I recently built and deployed a full-stack Django application from scratch and I made a ton of mistakes along the way. There were critical things I overlooked, especially during deployment, that could’ve caused major security and performance issues.</p><p>To save you from the same pain, I’ve put together this list of 17 must-do checks every Django developer should complete before going live.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7sgQeCY-oX56MJV5QnDKIw.png" /></figure><h3><strong>17-Step Deployment Checklist for a Production-Ready Django App</strong></h3><h4><strong>1. Set Up Environment Variables Securely (.env &amp; SECRET_KEY)</strong></h4><p>Many sensitive values like API keys (e.g. OpenAI), database credentials, payment secrets etc. should never be committed to version control. Store them in a .env file and load them using tools like python-dotenv.</p><p>One critical value to secure this way is your DJANGO_SECRET_KEY. It powers Django’s cryptographic functions (like signing session and CSRF tokens) and must remain secret. Use a unique, random key for each project and never reuse or expose it.</p><pre>SECRET_KEY=YOUR_SECRECT_KEY<br>OPENAI_API_KEY=OPENAI_API_KEY<br>DATABASE_URL=POSTGRES_DB_URL</pre><h4>2. Disable Debug Mode for Production Safety (DEBUG = False)</h4><p>Never run your application with DEBUG = True in production. It exposes sensitive information such as error logs, settings, and environment variables making your app highly vulnerable to attacks.</p><pre>DEBUG = False</pre><h4>3. Define Trusted Hosts with ALLOWED_HOSTS</h4><p>Explicitly define which domains or IP addresses can access your backend services to prevent unauthorized access.</p><pre>ALLOWED_HOSTS = [&quot;yourdomain.com&quot;, &quot;www.yourdomain.com&quot;]</pre><h4>4. Enable Security Middleware and Headers</h4><p>This protects your app from common vulnerabilities using Django’s in-built security middleware and recommended HTTP headers.</p><p>Ensure SecurityMiddleware is enabled in MIDDLEWARE (should be at the top):</p><pre>MIDDLEWARE = [<br>    &#39;django.middleware.security.SecurityMiddleware&#39;,<br>    # other middleware...<br>]</pre><p>Set secure HTTP headers in settings.py:</p><pre>SECURE_BROWSER_XSS_FILTER = True  <br>SECURE_CONTENT_TYPE_NOSNIFF = True  <br>X_FRAME_OPTIONS = &#39;DENY&#39;  <br>SECURE_HSTS_SECONDS = 31536000  <br>SECURE_HSTS_INCLUDE_SUBDOMAINS = True<br>SECURE_HSTS_PRELOAD = True<br>SECURE_SSL_REDIRECT = True  <br>SESSION_COOKIE_SECURE = True <br>CSRF_COOKIE_SECURE = True</pre><h4>5. Serve Static and Media Files Properly</h4><p>In production, Django does not serve static and media files. Consider using Whitenoise for smaller application and NGINX or S3/CDNs for larger ones.</p><p>Add path for static and media files in settings.py:</p><pre>STATIC_URL = &#39;/static/&#39;<br>STATIC_ROOT = os.path.join(BASE_DIR, &#39;staticfiles&#39;)<br><br>MEDIA_URL = &#39;/media/&#39;<br>MEDIA_ROOT = os.path.join(BASE_DIR, &#39;media&#39;)</pre><p>Then, run the following command:</p><pre>python manage.py collectstatic </pre><h4>6. Freeze and Review Dependencies in requirements.txt</h4><p>Make sure all the Python packages your application depends on are listed in requirements.txt. To update this file with every package installed in your virtual environment, run:</p><pre>pip freeze &gt; requirements.txt</pre><h4>7. Database Configurations</h4><p>Always load database credentials securely from environment variables. For production avoid using SQLite instead use robust databases like PostgreSQL or MySQL.</p><pre>DATABASES = {<br>    &#39;default&#39;: {<br>        &#39;ENGINE&#39;: &#39;django.db.backends.postgresql&#39;,<br>        &#39;NAME&#39;: os.getenv(&quot;DB_NAME&quot;),<br>        &#39;USER&#39;: os.getenv(&quot;DB_USER&quot;),<br>        &#39;PASSWORD&#39;: os.getenv(&quot;DB_PASSWORD&quot;),<br>        &#39;HOST&#39;: os.getenv(&quot;DB_HOST&quot;),<br>        &#39;PORT&#39;: os.getenv(&quot;DB_PORT&quot;),<br>    }<br>}</pre><h4>8. Split settings.py into base.py and prod.py (Optional)</h4><p>Even after deploying your app, you might want to keep working on it. But flipping back and forth between production and development settings can be troublesome and risky.</p><p>To keep things clean and safe, separate environment-specific configs like debug modes, database connections and allowed hosts clearly.</p><pre>project/<br>├── settings/<br>│   ├── base.py       # Common settings for all environments<br>│   ├── dev.py        # Development-specific settings (DEBUG=True, local DB)<br>│   └── prod.py       # Production-specific settings (DEBUG=False, secure configs)</pre><h4>9. Run Django’s Built-In Deployment Checks</h4><p>Django includes built-in deployment check commands that help identify common misconfigurations before going live. Always run these checks after modifying settings.py or before deploying to catch potential issues early.</p><pre>python manage.py check --deploy</pre><h4>10. Use a Production-Grade WSGI Server (e.g., Gunicorn)</h4><p>Django’s built-in development server is not designed for production use. It lacks robustness needed to handle real traffic, hence use use a production-ready WSGI server like Gunicorn or uWSGI.</p><pre>gunicorn myproject.wsgi:application --bind 0.0.0.0:8000</pre><p>Bonus: Run Gunicorn behind a reverse proxy server like NGINX. It can handle static file serving, HTTPS (TLS), load balancing, and can forward requests to Gunicorn.</p><h4>11. Consider using CDN or S3 for Performance (Optional)</h4><p>Consider offloading your static and media files to services like AWS S3 or Cloudfare for better page load speed and faster delivery.</p><h4>12. Restrict Admin Panel Access (e.g., IP Whitelisting)</h4><p>You can essentially control your entire site with Django’s admin panel. Hence, it is important to limit access to the admin route to only trusted IP addresses.</p><p>We can do this by checking the IP address of incoming requests to /admin route and blocking any IPs not on our trusted IP list.</p><pre>from django.http import HttpResponseForbidden<br><br>ALLOWED_ADMIN_IPS = [&#39;123.456.789.000&#39;]<br><br>class AdminIPWhitelistMiddleware:<br>    def __init__(self, get_response):<br>        self.get_response = get_response<br><br>    def __call__(self, request):<br>        if request.path.startswith(&#39;/admin/&#39;) and request.META.get(&#39;REMOTE_ADDR&#39;) not in ALLOWED_ADMIN_IPS:<br>            return HttpResponseForbidden(&quot;Access denied&quot;)<br>        return self.get_response(request)</pre><h4>13. Containerize with Docker for Environment Isolation</h4><p>Docker packages your application, its dependencies, and environment into a portable container that runs consistently across any system, effectively eliminating the “it works on my machine” problem.</p><h4>14. Final Code Cleanup: Remove Unused Code and Test Data</h4><p>Before deployment, clean your repo and remove any unused views, mock data or dummy media files.</p><h4>15. Turn Off Auto-Generated API Docs (e.g., Swagger in DRF)</h4><p>Do not ever expose auto-generated API docs (like Swagger or ReDoc) in production without protections.</p><p>Either disable them entirely (recommended) or gate them behind proper authentication.</p><h4>16. Perform Manual and Automated System Integrity Checks</h4><p>Perform both manual and automated tests to ensure the integrity of critical user flows such as authentication, payments, form submissions and admin access.<br> Use Django’s built-in test runner to execute all tests defined in your tests.py files:</p><pre>python manage.py test</pre><p>For API testing, consider using tools like Postman to validate API request/response behavior.</p><h4>17. Configure Logging and Monitoring</h4><p>Proper logging and monitoring are essential for identifying, debugging and resolving issues in production before they affect your users.</p><p>Django comes with a powerful built-in logging system based on Python’s logging module. You can configure it in settings.py:</p><pre>LOGGING = {<br>    &#39;version&#39;: 1,<br>    &#39;handlers&#39;: {<br>        &#39;file&#39;: {<br>            &#39;level&#39;: &#39;ERROR&#39;,<br>            &#39;class&#39;: &#39;logging.FileHandler&#39;,<br>            &#39;filename&#39;: &#39;/var/log/django/error.log&#39;,<br>        },<br>    },<br>    &#39;loggers&#39;: {<br>        &#39;django&#39;: {<br>            &#39;handlers&#39;: [&#39;file&#39;],<br>            &#39;level&#39;: &#39;ERROR&#39;,<br>            &#39;propagate&#39;: True,<br>        },<br>    },<br>}</pre><p>Optionally, for advanced logging and monitoring of your application consider using tools like Sentry or Logtail.</p><h3>Conclusion</h3><p>My final tip for a successful Django application deployment is to treat deployment as an ongoing process not a one and done type thing. Check audits regularly, update your code where it’s needed and check if critical user flows are still functioning as intended.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a2e7a8c49a8f" width="1" height="1" alt=""><hr><p><a href="https://python.plainenglish.io/17-essential-steps-to-prepare-your-django-app-for-production-a2e7a8c49a8f">17 Essential Steps to Prepare Your Django App for Production</a> was originally published in <a href="https://python.plainenglish.io/">Python in Plain English</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Overview Of Cyber Law In Nepal]]></title>
            <link>https://medium.com/@ankitpoudel_/overview-of-cyber-law-in-nepal-2634588ee24d?source=rss-afc564ef1b6a------2</link>
            <guid isPermaLink="false">https://medium.com/p/2634588ee24d</guid>
            <category><![CDATA[phishing]]></category>
            <category><![CDATA[cyber-law]]></category>
            <category><![CDATA[cyber-bullying]]></category>
            <category><![CDATA[identity-theft]]></category>
            <category><![CDATA[cyber-law-in-nepal]]></category>
            <dc:creator><![CDATA[Ankit Poudel]]></dc:creator>
            <pubDate>Tue, 18 Jul 2023 14:56:56 GMT</pubDate>
            <atom:updated>2023-07-18T14:56:56.307Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="Cyber Law In Nepal" src="https://cdn-images-1.medium.com/max/500/0*nxbieMiI3wR9l6X_.png" /></figure><blockquote><em>Cyber law can be defined as the area of law that deals with all aspects of cyberspace, the internet and other internet-related technology. This is one of the newest area of legal system. Cyber law in Nepal is called Electronics Transactions Act, 2063 which was created in response to growth of internet usage in Nepal on September 2, 2063. It deals with commercial use of computers and criminalizes various computer related illegal activities.</em></blockquote><p>In today highly digital world, the technological advancements has taken center stage in our lives whether we like our not. It has transformed the way we communicate, work and conduct our business in our day to day life. However, with our increase dependence on internet and technology as a whole, it has brought forth new challenges for us in form of cyber crime. In Nepal, as in many other countries, we have cyber laws to protect individuals and organizations from these attacks and crimes.</p><p>In this article we are going to discuss about cyber law in Nepal. And are the laws that are enacted by our government to protect us from these cyber crimes.</p><h3>What is cyber crime?</h3><p>The criminal activities that are carried out using digital means or internet is known as cyber crime. In other words, the crimes related to any illicit or illegal behavior carried out by or in relation to internet or computer network is called cyber crime.</p><p>With advent of internet and mobile phone access in every corner of the country, there have been significant rise in cyber crime through means such as social media and messaging apps. This includes everything from cyber bullying, use of internet for illegal activities, phishing scams, hacking, identity theft, malware attacks and so on.</p><h3>Definition of Cyber Law In Nepal</h3><p>To regulate these cyber crimes, each nation has its own cyber laws to protect its citizen, similar is the case for Nepal. On 2 September, 2063, then parliament passed the first cyber law in Nepal called Electronics Transactions Act, 2063. The objective of this bill was to mitigate crimes related to internet and digital properties.</p><p>This law deals with digital signature, identity theft, intellectual property, unauthorized use and alteration of electronic records and so on. Electronic Transactions Act controls any and all illicit activities done through the means of internet and helps to protect Nepali citizens against cyber crimes.</p><p>As per this Electronic Transactions Act, if a person is found violating any cyber laws or involving in illegal activities through internet, he/she will have to face minimum of 6 months to maximum of 3 years in prison. In addition to this, they would also have to pay minimum of 50 thousand to a maximum of 3 Lakhs as penalty.</p><blockquote><em>According to Electronic Transactions Act, “Whoever publishes or causes to publish, display any material in the electronic form including computer, internet which are prohibited to publish or display by the law in force or which may be contrary to the public morality or decent behavior or any types of materials which may spread hate or jealousy against anyone or which may jeopardize the harmonious relations subsisting among the peoples of various castes, tribes and communities shall be liable to be punished with a fine of up to one hundred thousand rupees or with imprisonment of up to five years or both.”</em></blockquote><h3>Different Cyber Laws In Nepal</h3><h4>1. Electronic Transactions Act, 2063</h4><p>This was the first cyber law in Nepal, introduced on September 2, 2063 to combat the cyber crimes caused due to sudden growth of internet and computer use in Nepali households at that time. Before enactment of this law, all cyber crimes in Nepal were dealt under the country’s criminal code. It deals with unauthorized use and adulteration of electronic records among other things.</p><p>According to this law, “Stealing, pirating or destroying someone else’s computer system or accessing it without proper authorization will result in 3 years of imprisonment or 2 thousand rupees fine or both. Also, publication of illegal material in electronic form can land you in prison for 5 years or a fine of 1 hundred thousand rupees or both.”</p><p><strong>To read in detail about other Cyber Laws in Nepal. And how these laws are enacted by our government to protect us from these cyber crimes, refer to my latest blog on my website: </strong><a href="https://www.ankit-poudel.com.np/2023/07/overview-of-cyber-law-in-nepal.html"><strong>Overview Of Cyber Law In Nepal</strong></a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2634588ee24d" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>