<?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: Purnima Chowrasia</title>
    <description>The latest articles on DEV Community by Purnima Chowrasia (@purnima_chowrasia).</description>
    <link>https://dev.to/purnima_chowrasia</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%2F3270496%2F7e5e433c-7f49-41c3-86f8-fc098273363a.jpg</url>
      <title>DEV Community: Purnima Chowrasia</title>
      <link>https://dev.to/purnima_chowrasia</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/purnima_chowrasia"/>
    <language>en</language>
    <item>
      <title>Found something cool while vibe coding: Response interceptors</title>
      <dc:creator>Purnima Chowrasia</dc:creator>
      <pubDate>Tue, 15 Jul 2025 15:28:12 +0000</pubDate>
      <link>https://dev.to/purnima_chowrasia/found-something-cool-while-vibe-coding-response-interceptors-563l</link>
      <guid>https://dev.to/purnima_chowrasia/found-something-cool-while-vibe-coding-response-interceptors-563l</guid>
      <description>&lt;p&gt;So I was vibe coding a React frontend over the weekend(yeah, backend dev trying frontend things 😅), and stumbled across something called &lt;strong&gt;axios response interceptors&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;This frontend pattern made me go “wait, THAT’s how they handle this?!”&lt;/p&gt;

&lt;h2&gt;
  
  
  The Problem I Never Thought About
&lt;/h2&gt;

&lt;p&gt;From the backend, I send a 401 when tokens expire. Simple, right? But I never really thought about what happens on the frontend when users are mid-action…&lt;/p&gt;

&lt;p&gt;Imagine: User spends 10 minutes filling a form, hits submit, token expired 2 minutes ago → 401 → user sees error → has to re-login → &lt;strong&gt;loses all their work&lt;/strong&gt;. Brutal.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Frontend Magic I Discovered
&lt;/h2&gt;

&lt;p&gt;Response interceptors essentially create this flow:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;API call → 401 response → Interceptor catches it → Auto-refreshes token → Retries original call → User gets response
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The user literally never knows their token expired. Pretty amazing ha…&lt;/p&gt;

&lt;p&gt;Similar to response interceptor, axios has request interceptor too. No need repeat the code for sending access token or any other headers with every api call you are making in the codebase. Just write once i.e a request interceptor. &lt;/p&gt;

&lt;h2&gt;
  
  
  Why This Impressed My Backend Brain
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Centralized error handling&lt;/strong&gt; (like middleware)&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Automatic retry logic&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Transparent to business logic&lt;/strong&gt; (clean separation of concerns)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Works across the entire app&lt;/strong&gt; (write it once, forget it)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This is why I love stepping outside my backend comfort zone occasionally. You discover patterns and solutions you'd never encounter otherwise. Makes me appreciate the frontend folks even more! 🙌&lt;/p&gt;

</description>
      <category>backenddevelopment</category>
      <category>frontend</category>
      <category>vibecoding</category>
      <category>webdev</category>
    </item>
    <item>
      <title>#5 Django Journey: Learn DRF by building an e-commerce APIs</title>
      <dc:creator>Purnima Chowrasia</dc:creator>
      <pubDate>Sun, 29 Jun 2025 14:36:27 +0000</pubDate>
      <link>https://dev.to/purnima_chowrasia/5-django-journey-learn-drf-by-building-an-e-commerce-apis-4mcp</link>
      <guid>https://dev.to/purnima_chowrasia/5-django-journey-learn-drf-by-building-an-e-commerce-apis-4mcp</guid>
      <description>&lt;p&gt;Hey dev.to community!&lt;/p&gt;

&lt;h2&gt;
  
  
  Update: User authentication Part 2
&lt;/h2&gt;

&lt;p&gt;In user authentication part 1, I mentioned about starting with Token based authentication and securing product model. I have further extended this authentication feature with these added functionality:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Both Product and Category models are protected: Only authenticated user can create POST/PUT/DELETE request. Anonymous user can only view the product and category, they cannot make any modification.&lt;/li&gt;
&lt;li&gt;Built user profile: This route allowed user to view their profile and update their profile details.&lt;/li&gt;
&lt;li&gt;Added change password functionality: Logged in user can change their password and on successful change of password their old token gets deleted and a new token is generated.&lt;/li&gt;
&lt;li&gt;Added logout functionality: Logged in user can now logout, that means their token will be deleted. So the token they received on login is no longer valid.&lt;/li&gt;
&lt;li&gt;Testing: Tested deleting or updating product or category only when logged in. Tested that authenticated user can view their profile, change password and logout.&lt;/li&gt;
&lt;/ol&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%2Fg4mmc1p2gt9sis6anvor.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%2Fg4mmc1p2gt9sis6anvor.png" alt="Image description" width="800" height="327"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;See you’ll next time.. bye 👋&lt;/p&gt;

&lt;p&gt;Complete code available &lt;a href="https://github.com/purnima291/drf_ecommerce_api/tree/phase-3/user-authentication" rel="noopener noreferrer"&gt;here&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>django</category>
      <category>buildinpublic</category>
      <category>python</category>
    </item>
    <item>
      <title>#4 Django Journey: Learn DRF by building an e-commerce APIs</title>
      <dc:creator>Purnima Chowrasia</dc:creator>
      <pubDate>Thu, 26 Jun 2025 14:19:04 +0000</pubDate>
      <link>https://dev.to/purnima_chowrasia/4-django-journey-learn-drf-by-building-an-e-commerce-apis-377o</link>
      <guid>https://dev.to/purnima_chowrasia/4-django-journey-learn-drf-by-building-an-e-commerce-apis-377o</guid>
      <description>&lt;p&gt;Hey dev.to community!&lt;/p&gt;

&lt;h2&gt;
  
  
  Update: User authentication Part 1
&lt;/h2&gt;

&lt;p&gt;Here I am to share an update about my progress in this project. As a last update on this project, where I have mentioned about adding Category model and established a relationship between product and category. This time I have worked on user authentication:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Create an &lt;code&gt;accounts&lt;/code&gt; app to manage user registration and login.&lt;/li&gt;
&lt;li&gt;Used Token-based API authentication.&lt;/li&gt;
&lt;li&gt;On User registration, token is generated and stored in authtoken_token DB table.&lt;/li&gt;
&lt;li&gt;On Login, token is retrieved.&lt;/li&gt;
&lt;li&gt;API to create product has been restricted only for logged in user.&lt;/li&gt;
&lt;li&gt;Token is now needed to be sent in the header to create product.&lt;/li&gt;
&lt;li&gt;Product can be view by user without login.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Why I have used Token-based authentication instead of JWT-authentication or session-based authentication?
&lt;/h2&gt;

&lt;p&gt;Token-based authentication is easier to get started and simple to understand. When a new user registers, a token is generated and stored in the database. So every time a user has to access any protected API, they have to send this token in the header. This token never expires and is stateless.&lt;/p&gt;

&lt;p&gt;However here are &lt;strong&gt;some disadvantages of Token-based authentication:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Token never expires(security risk)&lt;/li&gt;
&lt;li&gt;If token compromised then, it’s valid forever&lt;/li&gt;
&lt;li&gt;No refresh mechanism&lt;/li&gt;
&lt;li&gt;One token per user, can’t track multiple devices login.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;In future projects, I would definitely love to explore JWT and session based authentication. Meanwhile, please share your thought and tell me about your projects that you have worked.&lt;/p&gt;

&lt;p&gt;See you’ll next time.. bye 👋&lt;/p&gt;

&lt;p&gt;Complete code available &lt;a href="https://github.com/purnima291/drf_ecommerce_api/tree/phase-3/user-authentication" rel="noopener noreferrer"&gt;here&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>django</category>
      <category>buildinpublic</category>
      <category>python</category>
    </item>
    <item>
      <title>#3 Django Journey: Why I Added Slugs to My Product Model (And You Should Too)?</title>
      <dc:creator>Purnima Chowrasia</dc:creator>
      <pubDate>Sat, 21 Jun 2025 14:47:03 +0000</pubDate>
      <link>https://dev.to/purnima_chowrasia/3-django-journey-why-i-added-slugs-to-my-product-model-and-you-should-too-4067</link>
      <guid>https://dev.to/purnima_chowrasia/3-django-journey-why-i-added-slugs-to-my-product-model-and-you-should-too-4067</guid>
      <description>&lt;p&gt;Hey dev.to community!&lt;/p&gt;

&lt;p&gt;Which URL is easy to remember? This &lt;code&gt;products/wireless-headphone/&lt;/code&gt; or this &lt;code&gt;products/uuidxyz2292992/&lt;/code&gt;? For me &lt;code&gt;products/wireless-headphone/&lt;/code&gt; url is easy to note.&lt;/p&gt;

&lt;h2&gt;
  
  
  🌟 What is Slugs?
&lt;/h2&gt;

&lt;p&gt;A slug is a URL-friendly version of a string, typically derived from a title, description or name. It only contains lowercase letters, numbers, and hyphens. This term ‘slug’ comes from newspaper publishing, where it referred to a short name used to identify a story.&lt;/p&gt;

&lt;p&gt;Example: "Django Slugs: Complete Guide" → &lt;code&gt;django-slugs-complete-guide&lt;/code&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  🌟 Why use Slugs?
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;SEO Benefits:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;/api/products/wireless-bluetooth-headphones/&lt;/code&gt; is much better than &lt;code&gt;/api/products/47/&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Search engines love descriptive URLs&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;User Experience:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;URLs are readable and shareable&lt;/li&gt;
&lt;li&gt;Users can guess what the URL might be and can modify URLs to find similar products&lt;/li&gt;
&lt;li&gt;More professional-looking API&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Security:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Doesn't expose your database ID sequence&lt;/li&gt;
&lt;li&gt;Harder for people to guess other product IDs&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  📌 Basic Slug Implementation
&lt;/h2&gt;

&lt;p&gt;Django makes working with slugs incredibly straightforward with the built-in &lt;code&gt;SlugField&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;django.db&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;models&lt;/span&gt;

&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Product&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;models&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Model&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="n"&gt;name&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;models&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;CharField&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;max_length&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;200&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;slug&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;models&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;SlugField&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;max_length&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;200&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;unique&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="bp"&gt;True&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;blank&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="bp"&gt;True&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;description&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;models&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;TextField&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;

    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;__str__&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;name&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  📌 Auto-Generate Slugs
&lt;/h2&gt;

&lt;p&gt;Manual entry in Slug field can get tedious, we can automate this by using Django’s &lt;code&gt;slugify&lt;/code&gt; function:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;django.db&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;models&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;django.utils.text&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;slugify&lt;/span&gt;

&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Product&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;models&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Model&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="n"&gt;name&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;models&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;CharField&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;max_length&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;200&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;slug&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;models&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;SlugField&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;max_length&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;200&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;unique&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="bp"&gt;True&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;blank&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="bp"&gt;True&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;description&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;models&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;TextField&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;    

    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;save&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="n"&gt;args&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="o"&gt;**&lt;/span&gt;&lt;span class="n"&gt;kwargs&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="ow"&gt;not&lt;/span&gt; &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;slug&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;slug&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;slugify&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="nf"&gt;super&lt;/span&gt;&lt;span class="p"&gt;().&lt;/span&gt;&lt;span class="nf"&gt;save&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="n"&gt;args&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="o"&gt;**&lt;/span&gt;&lt;span class="n"&gt;kwargs&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;When we create a new product with name ‘Python Best Practice Book’, the slug automatically becomes &lt;code&gt;python-best-practice-book&lt;/code&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  📌 Handling Duplicate Slugs
&lt;/h2&gt;

&lt;p&gt;What happens when two post have the same title? We need to handle duplicates gracefully:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;django.db&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;models&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;django.utils.text&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;slugify&lt;/span&gt;

&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Product&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;models&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Model&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="n"&gt;name&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;models&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;CharField&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;max_length&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;200&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;slug&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;models&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;SlugField&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;max_length&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;200&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;unique&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="bp"&gt;True&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;blank&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="bp"&gt;True&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;description&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;models&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;TextField&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; 

       &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;save&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="n"&gt;args&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="o"&gt;**&lt;/span&gt;&lt;span class="n"&gt;kwargs&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
           &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="ow"&gt;not&lt;/span&gt; &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;slug&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
               &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;slug&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;slugify&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
               &lt;span class="n"&gt;unique_slug&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;slug&lt;/span&gt;
               &lt;span class="n"&gt;counter&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;

               &lt;span class="k"&gt;while&lt;/span&gt; &lt;span class="n"&gt;Product&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;objects&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;filter&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;slug&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;unique_slug&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;exists&lt;/span&gt;&lt;span class="p"&gt;():&lt;/span&gt;
                   &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;slug&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;unique_slug&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s"&gt;-&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;counter&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;
                   &lt;span class="n"&gt;counter&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;
           &lt;span class="nf"&gt;super&lt;/span&gt;&lt;span class="p"&gt;().&lt;/span&gt;&lt;span class="nf"&gt;save&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="n"&gt;args&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="o"&gt;**&lt;/span&gt;&lt;span class="n"&gt;kwargs&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

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

&lt;/div&gt;



&lt;p&gt;This creates slugs like &lt;code&gt;headphone&lt;/code&gt;, &lt;code&gt;headphone-1&lt;/code&gt;, &lt;code&gt;headphone-2&lt;/code&gt; to handle duplicate names.&lt;/p&gt;

&lt;h2&gt;
  
  
  🖌️ End Notes
&lt;/h2&gt;

&lt;p&gt;To make our project or application more professional and top notch, one should definitely utilise Django’s slug functionality wherever we can.&lt;/p&gt;

&lt;p&gt;Let me know, in the comments about your project where you discovered slug for the first time and how it improved you application? Or may be share some of the advanced slug techniques that you have used in your project.&lt;/p&gt;

&lt;p&gt;Reference: &lt;a href="https://learndjango.com/tutorials/django-slug-tutorial" rel="noopener noreferrer"&gt;https://learndjango.com/tutorials/django-slug-tutorial&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;See you’ll next time.. bye 👋&lt;/p&gt;

</description>
      <category>django</category>
      <category>python</category>
      <category>programming</category>
      <category>webdev</category>
    </item>
    <item>
      <title>#2 Django Journey: Learn DRF by building an e-commerce APIs</title>
      <dc:creator>Purnima Chowrasia</dc:creator>
      <pubDate>Fri, 20 Jun 2025 04:38:24 +0000</pubDate>
      <link>https://dev.to/purnima_chowrasia/2-django-journey-learn-drf-by-building-an-e-commerce-apis-4pla</link>
      <guid>https://dev.to/purnima_chowrasia/2-django-journey-learn-drf-by-building-an-e-commerce-apis-4pla</guid>
      <description>&lt;p&gt;Hey dev.to community!&lt;/p&gt;

&lt;p&gt;In continuation to my &lt;a href="https://dev.to/purnima_chowrasia/1-django-journey-learn-drf-by-building-an-e-commerce-apis-1392"&gt;previous post&lt;/a&gt;, where I mentioned about working on building Products app, CRUD operation related to Products. Now, here is the current progress that I wanted share with you all:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Create a Category model.&lt;/li&gt;
&lt;li&gt;Modified the existing Product model to add category as Foreign key field.&lt;/li&gt;
&lt;li&gt;Applied Database migration. &lt;/li&gt;
&lt;li&gt;Added Category serializer, with a addon serializer method inside the respective serializer class to get product count for a particular category.&lt;/li&gt;
&lt;li&gt;Modified Product serializer to show category info as nesting category serializer.&lt;/li&gt;
&lt;li&gt;Created APIs to handle CRUD operation on Category.&lt;/li&gt;
&lt;li&gt;Registered both Product and Category models on Django admin interface for easy data management.&lt;/li&gt;
&lt;li&gt;Created superuser and interacted with Django Admin interface.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;While applying database migration, I encountered an issue as I have some data already added as Products. And no data under Category were available. Here is how I solved this(definitely with the help of prompting LLM):&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Deleting migration file which got created when executing &lt;code&gt;makemigrations&lt;/code&gt; command.&lt;/li&gt;
&lt;li&gt;Commented out category field(Foreign key) in Product model. &lt;/li&gt;
&lt;li&gt;Applied migration only for creating Category model in Database.&lt;/li&gt;
&lt;li&gt;Then added data in Category model using shell command.&lt;/li&gt;
&lt;li&gt;Uncommented, category field(Foreign key) in Product model. &lt;/li&gt;
&lt;li&gt;Applied migrations again, it asked for some default value to be added in category field in existing product data. Chose the option 1. &lt;/li&gt;
&lt;li&gt;And issue sorted. I believe, there can be other ways to sort this issue.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Overall, it was a great experience to till now and hoping to keep going like this. Attaching ss of Django admin panel.&lt;br&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%2Fj1ozign50kwwwy4ph6dx.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%2Fj1ozign50kwwwy4ph6dx.png" alt="Django Admin panel" width="800" height="284"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Complete code available &lt;a href="https://github.com/purnima291/drf_ecommerce_api/tree/phase-2" rel="noopener noreferrer"&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Next, I will be working on User Authentication. See you next time..bye👋&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>django</category>
      <category>buildinpublic</category>
      <category>python</category>
    </item>
    <item>
      <title>#1 Django Journey: Learn DRF by building an e-commerce APIs</title>
      <dc:creator>Purnima Chowrasia</dc:creator>
      <pubDate>Wed, 18 Jun 2025 07:28:52 +0000</pubDate>
      <link>https://dev.to/purnima_chowrasia/1-django-journey-learn-drf-by-building-an-e-commerce-apis-1392</link>
      <guid>https://dev.to/purnima_chowrasia/1-django-journey-learn-drf-by-building-an-e-commerce-apis-1392</guid>
      <description>&lt;p&gt;Hey dev.to community!&lt;/p&gt;

&lt;p&gt;In my very &lt;a href="https://dev.to/purnima_chowrasia/django-journey-learn-drf-by-building-an-e-commerce-api-3lac"&gt;1st post&lt;/a&gt; where, I have decided to learn django by building small projects. Here is an update on my progress:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Did the initial project setup and created a Products app.&lt;/li&gt;
&lt;li&gt;Created a Product model with slug field which is generated automatically.&lt;/li&gt;
&lt;li&gt;With slugs SEO-friendly URLs can be created(will write more about this in future post).&lt;/li&gt;
&lt;li&gt;Created RESTful endpoints(GET, POST, PUT and DELETE). &lt;/li&gt;
&lt;li&gt;Create Product serializer.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;I am amazed by how using a few lines of code these APIs can be written utilising Django REST framework generic views. These generic views simplifies the creation of API endpoints for performing CRUD operations. For example, in this project I have created just two views which handles CRUD operations in few lines of code.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;ProductListCreateView: Uses &lt;em&gt;generics.ListCreateAPIView&lt;/em&gt; to get list of all the products(via GET request) and create a new product(via POST request).&lt;/li&gt;
&lt;li&gt;ProductDetailView: Uses &lt;em&gt;generics.RetrieveUpdateDestroyAPIView&lt;/em&gt; to get a single product(lookup based on slug field), PUT request to update a product, DELETE request to remove a product.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Another good thing is, Browsable API provided in DRF. One can interact with APIs, test and debug it. &lt;/p&gt;

&lt;p&gt;Next, I will be working on Categories of the product, expand CRUD operation to categories and get into django admin interface. Also attached some screenshots of the APIs and code.&lt;br&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%2Fho3lg2bwwe3rx1po4u1y.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%2Fho3lg2bwwe3rx1po4u1y.png" alt="Image description" width="800" height="529"&gt;&lt;/a&gt;&lt;br&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%2Fwahjiu6fzqrmxm4ttwz4.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%2Fwahjiu6fzqrmxm4ttwz4.png" alt="Image description" width="800" height="390"&gt;&lt;/a&gt;&lt;br&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%2Fd69wd2l8a8oljzxe4zbg.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%2Fd69wd2l8a8oljzxe4zbg.png" alt="Image description" width="800" height="388"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Complete code available &lt;a href="https://github.com/purnima291/drf_ecommerce_api/tree/phase-1" rel="noopener noreferrer"&gt;here&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>buildinpublic</category>
      <category>django</category>
      <category>webdev</category>
      <category>beginners</category>
    </item>
    <item>
      <title>Django Journey: Learn DRF by building an e-commerce API</title>
      <dc:creator>Purnima Chowrasia</dc:creator>
      <pubDate>Tue, 17 Jun 2025 13:49:39 +0000</pubDate>
      <link>https://dev.to/purnima_chowrasia/django-journey-learn-drf-by-building-an-e-commerce-api-3lac</link>
      <guid>https://dev.to/purnima_chowrasia/django-journey-learn-drf-by-building-an-e-commerce-api-3lac</guid>
      <description>&lt;p&gt;Hey dev.to community!&lt;/p&gt;

&lt;p&gt;I am familiar with python based web-framework such as flask, however from quite sometime I wanted to learn Django and DRF. I have picked few things here and there by watching some tutorials, following them, and reading blogs. But, the best way to learn anything is by doing. So I have decided to start with picking some common and simple projects, and build it publicly by sharing the progress weekly once/twice here on this platform. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;This is what I am building:&lt;/strong&gt;&lt;br&gt;
E-Commerce APIs with Django REST Framework&lt;br&gt;
-&amp;gt; User Authentication and management&lt;br&gt;
-&amp;gt; Product catalog and categories&lt;br&gt;
-&amp;gt; Shopping cart functionality&lt;br&gt;
-&amp;gt; Order processing system&lt;/p&gt;

&lt;p&gt;Github Link: &lt;a href="https://github.com/purnima291/drf_ecommerce_api" rel="noopener noreferrer"&gt;https://github.com/purnima291/drf_ecommerce_api&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Join Me and Follow Along!&lt;br&gt;
If you're also learning Django, or thinking about it, let's support each other! Drop a comment and let me know:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Are you learning Django too?&lt;/li&gt;
&lt;li&gt;What projects are you working on?&lt;/li&gt;
&lt;li&gt;Any advice?&lt;/li&gt;
&lt;li&gt;Want to follow along and maybe build something similar?&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>django</category>
      <category>python</category>
      <category>buildinpublic</category>
      <category>beginners</category>
    </item>
  </channel>
</rss>
