<?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 Parthib Deb on Medium]]></title>
        <description><![CDATA[Stories by Parthib Deb on Medium]]></description>
        <link>https://medium.com/@parthibkumardeb?source=rss-2e5aba4f5ccf------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*mtcdcraM2eBDXomZ9Z_2xA.jpeg</url>
            <title>Stories by Parthib Deb on Medium</title>
            <link>https://medium.com/@parthibkumardeb?source=rss-2e5aba4f5ccf------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 21 Nov 2026 02:44:36 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@parthibkumardeb/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[DJANGO AUTH : Handling POST request with ‘User’ model]]></title>
            <link>https://medium.com/@parthibkumardeb/django-auth-handling-post-request-with-user-model-2e76eaa785ee?source=rss-2e5aba4f5ccf------2</link>
            <guid isPermaLink="false">https://medium.com/p/2e76eaa785ee</guid>
            <category><![CDATA[django]]></category>
            <category><![CDATA[python3]]></category>
            <category><![CDATA[authentication]]></category>
            <dc:creator><![CDATA[Parthib Deb]]></dc:creator>
            <pubDate>Fri, 14 Jul 2023 07:41:22 GMT</pubDate>
            <atom:updated>2023-07-16T05:27:05.715Z</atom:updated>
            <content:encoded><![CDATA[<h3><strong>DJANGO AUTH : Juggling POST request for ‘User’ model</strong></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KP-gAw3qIkwNits2d5yjFw.png" /></figure><p>Welcome back, everyone!! Today’s topic is a little more fascinating, as you can tell by the name, so without any further delay, let’s get started!!</p><p>Whether it is a web app or a mobile app, user authentication is a crucial issue for any client-oriented product. Because of this, offering a robust user-authentication and permission capability is a mandatory feature for every modern framework — Django is not an exception to this rule. It has its own path for handling it; after all, we are aware that there is an admin panel incorporated into the software that allows us to view every <strong>user’s tracks and datas </strong>, as well as their <strong>account history </strong>!! Django already has a built-in user model for verification of users — ( <strong>path : </strong><em>from django.contrib.auth.models import User) </em>. The <strong>user </strong>model consists of all these fields : <strong>username , email , password , first_name(blank=True) , last_name(blank=True) </strong>and <strong>many more methods. </strong>Django informs us that <strong>first_name</strong> and <strong>last_name</strong> are not mandatory fields to fill out ; however, there will be some default garbage values to be filled in in the database. It only focuses on the user’s <strong>username, email,</strong> and <strong>password</strong> (it will throw an exception if a new user’s username is found to be identical to an existing one; but for email and password validation, we must write our own logic). This is the <strong>simplest version of user model</strong> , inherited from <strong>AbstractUser</strong> model , which also comes from <strong>AbstractBaseUser </strong>model . Seems like the tree got a deep root on its underneath !! Isn’t it?? Now here comes a question!! — How to use this simplest , yet beautiful gift from django — see, there are many ways to handle it ; depends upon the situation and the necessities that you expects from the model, here I want to put some light on two different categories of <strong>views</strong> logics to handle <em>POST </em>request — <strong><em>WITH FORM </em></strong>, <strong><em>WITHOUT FORM</em></strong></p><ol><li><strong>WITH FORM : </strong>We know that , django is already a fullstack framework from its birth. So, it provides a very good interface to handle <strong>HTML forms </strong>that will take input values according to the fields declared in the models — <strong>ModelForm.</strong> A ModelForm is a very Convenient approach to just simply set-up this connection rather than having to create separate forms classes based on the model fields and connect with the label-names of the HTML form tags. so , there are two modelforms that we can use — <strong><em>UserCreationForm </em></strong>or Own ModelForm.</li></ol><blockquote>Despite the fact that , the user model has numerous built-in modelforms of this type ,I’d like to make this conversation light, while still explaining the distinctions . So I am stick with these two forms only for this discussion.</blockquote><ol><li>A. <strong>UserCreationForm (Path — </strong><em>from django.contrib.auth.forms import UserCreationForm) </em>:</li></ol><pre>#forms.py<br><br>from django.contrib.auth.models import User<br>from django.contrib.auth.forms import UserCreationForm<br><br>class UserRegistrationForm(UserCreationForm):<br>  class Meta:<br>    model = User<br>    fields = &quot;__all__&quot; <br>&#39;&#39;&#39;<br>fields of UsercreationForm : username , email ,<br>                 password1, password2(confirmation)<br>&#39;&#39;&#39;</pre><p>Here we can see , that UsercreationForm consists of only 4 fields — <strong>username , email , password , confirm password . </strong>That means, this basic form very much focuses on username as well as password verification. Quite impressive!!! Django is just showering blessings!! But here you can see there are no fields for user’s <strong>first_name </strong>and <strong>last_name </strong>(although, user model have those fields). so now , if you want to add user’s names sections— then you have to make some changes in the parent model of user , that is the <strong>AbstractUser </strong>(if you wish to work with UserCreationForm)</p><pre>#models.py<br><br>from django.contrib.auth.models import AbstractUser<br><br>class NewUser(AbstractUser):<br>    first_name=models.Charfield(max_length=150)<br>    last_name=models.Charfield(max_length=150)<br><br>    # add any other fields if you want to<br><br>    def __str__(self):<br>        return self.username<br><br>#settings.py<br><br>AUTH_USER_MODEL = &#39;APP_NAME.NewUser&#39; <br>#as we have created a new user model for this project only<br><br>#forms.py<br><br>from django.contrib.auth.forms import UserCreationForm<br>from myapp.models import *<br><br>class CustomUserRegistrationForm(UserCreationForm):<br>    class Meta(UserCreationForm.Meta):<br>        model = NewUser<br>        fields = UserCreationForm.Meta.fields + (&quot;custom_field&quot;,)</pre><p>Clearly, we can see that we are altering our AbstractUser model and creating a new User model for our particular project, and we see that the changes are reflected everywhere (from specifying the new user model’s name in <strong>settings</strong> to the <strong>forms</strong> file).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MrV3XHs6z0pavU9Ci4ENHA.jpeg" /></figure><ol><li>B. <strong>Own ModelForm (path: </strong><em>from django.forms import ModelForm</em><strong>) :</strong> Otherwise, if we don’t want to go with UserCreationForm , we can create our own ModelForm, like we do for other custom models . Here we have to remind that , we just want to use the fields of the given user model’s fields without any extra facilities.</li></ol><pre>#forms.py<br>from django.contrib.auth.models import User<br>from django import forms<br><br>class UserRegistrationForm(forms.Modelform):<br>  class Meta:<br>    model = User<br>    fields = &quot;__all__&quot;<br>&#39;&#39;&#39;<br>Fields are : username, email, password, first_name, last_name<br>&#39;&#39;&#39;</pre><p>Although , we can use first and last_name fields of user, which is helful for showing user’s identity in front-end , for sending emails , but <strong>here password verification is missing !!</strong> Maybe it is true that- sometimes a blessings also comes with some cost!! We maynot have the direct access to some pre-dominant validations if we use the model is this way (but yeah!! it’s all depends on situations!!)</p><p>For all the ways incorporating <strong>django-forms,</strong> the <strong>common and bare views logics</strong> will be same (I told bare!! because, yeah you must add some other stuffs in your views to upgrade your logic , but this is the skeleton — if you use forms)</p><pre>#views.py ( for all types of forms )<br><br>from django.contrib.auth.models import User<br>from .forms import *<br>from django.shortcurts import render,redirect<br><br>def signIn(request):<br>  form=UserRegistrationForm()<br>  if request.method == &quot;POST:<br>      form=UserRegistrationForm(request.POST)<br>      if form.is_valid():<br>          form.save(commit=False) # make sure that you have redefined this method<br>                                   # in forms.py<br>          #Otherwise<br>          &#39;&#39;&#39;<br>              User.objects.create_user(<br>                            username=request.POST[&#39;username&#39;],<br>                            email=request.POST[&#39;email&#39;],<br>                            password=request.POST[&#39;password&#39;] # after validation<br>                            )<br>              User.first_name=request.POST[&#39;first_name&#39;]<br>              User.last_name=request.POST[&#39;last_name&#39;]<br>              User.save()<br>               # without using &#39;request.POST&#39; as a raw dictionary , you can use<br>                # form.cleaned_data[&#39;___&#39;], specially if you want to redirect in signin page<br>          &#39;&#39;&#39;<br>          #some redirect page<br>  else:<br>      return render(request,&quot;signin.html&quot;,{&quot;form&quot;:form})</pre><p>This clearly demonstrates that, we are using either <em>‘request.POST’</em> dictionary or <em>‘form.cleaned_data[‘___’]’ </em>to get specific data. Else , we can use <strong>create </strong>api without using <strong>create_user </strong>to provide the dataset as a collection.</p><p>2. <strong>WITHOUT FORM : </strong>It’s the most minimum and classic way to handle the input data without any hectic , here we just have to make sure that the <strong>&lt;label for = “___” , name = “__”&gt; </strong>must be matches with specific <strong>model field-names.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8RaLIdDu-6VF7dFhzMUggg.png" /><figcaption>views.py of my USER-AUTH project (without forms)</figcaption></figure><p>From my code , you can clearly understand that we just have to use the robust way of creating object by taking data from <strong>request.POST</strong> dictionary and calling queryset apis. Here I have not made any changes in in models or forms (although, I tried to use forms) , so it’s a primitive USER-AUTH obviously!!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/474/1*-98OHlZuzxBfS43hZ5YQkA.jpeg" /></figure><p>This was all about my viewpoint on how to handle POST request in authentication. On the top of this codes and logics, you can add your viewpoint to make it more better in terms of security and validations. Hope you have realized my words and what I want to tell. Will meet you in my next Blog!!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2e76eaa785ee" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[DJANGO vs all — Python REST war]]></title>
            <link>https://medium.com/@parthibkumardeb/django-vs-all-python-rest-war-87b12e8d13ae?source=rss-2e5aba4f5ccf------2</link>
            <guid isPermaLink="false">https://medium.com/p/87b12e8d13ae</guid>
            <category><![CDATA[django-rest-framework]]></category>
            <category><![CDATA[fastapi]]></category>
            <category><![CDATA[django]]></category>
            <category><![CDATA[python-programming]]></category>
            <category><![CDATA[python]]></category>
            <dc:creator><![CDATA[Parthib Deb]]></dc:creator>
            <pubDate>Mon, 01 May 2023 19:36:09 GMT</pubDate>
            <atom:updated>2025-07-29T16:43:02.432Z</atom:updated>
            <content:encoded><![CDATA[<h3>DJANGO vs all — Python REST war</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xnCxfwbzcmkeA7I9hp_gvA.png" /></figure><p>Good to see you all here !! so, I am going to discuss on an intimidating topic , going inside every modern web developer’s mind . First of all, let’s understand the context .</p><p>Since Python (especially after version 2s), with its slick , short , to the point syntax has started its non-stop demand through out a range of years. But when the story diverts to its web frameworks , we seems to get a great taste of python . Frameworks like <strong>Pyramid </strong>, <strong>Flask </strong>, <strong>Django and others </strong>develops the backend using python’s awesome syntaxes. So, why ‘vs’ ??…python has many frameworks for the web ,but efficiency of all those frameworks are not the same , that’s why you would hear only few names of python frameworks in today’s web dev world comparing to JS frameworks. Now you have to understand , what is a <strong>FRAMEWORK</strong> in general. so, In simple terms, <em>its a ready-made collections of components to build a good application. </em>That’s where, the conflict comes!!</p><p>Since all the frameworks have some basic pre-requisites for database connection (especially to the relational ones) and no other features for the well being of the website <strong>like providing security (Which comes through out the evolution in HTTP and www),</strong> no other default frontend managing facility , where you can put all your HTML,CSS and other client-side engine codes and can direct map those events with your models in one platform , <strong><em>DJANGO becomes an extraordinary exception !! </em></strong>Django provides a complete <strong><em>FULL STACK PLATFORM ,</em></strong>where you can literary code for client-side and merge them with appropriate server-side logics, obeying the <strong>MVT(MODEL-VIEW-TEMPLATE) architecture.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/315/1*aZZ1vji7wYdSvMhG8n6oNg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/269/1*WixxZHTxsA36dq_rT0RjOw.png" /><figcaption>Django Folder Structure for full stack purposes ( Screenshots of my project CODEFACTS)</figcaption></figure><p>Django also provides you a <strong>built-in admin panel</strong> and <strong>shell </strong>for all CRUD operations. Also ,Django takes very much care of <strong>AUTHENTICATION. </strong>You can add any third part app inside django’s <strong>settings.py (It’s a full stack configuration file) </strong>for specific purpose . So, you can see that how django was ahead of its time , <em>when the other backend frameworks were thinking about just making server side rendering by api , django took one step forward to reduce developer’s effort and make applications </em><strong><em>rapidly</em></strong><em>.</em></p><p>So, now what’s the situation ?? Fastforward 2021, when creation of <strong>FASTAPI </strong>happened , it starts to get popularity rapidly as you can see now. Basically it has solved the problem of connecting a python framework to a NOSQL database in a snap and reducing the ammount of code , inspired from flask !! so, that made a question on django developer’s mind — <strong>so, is the journey of the party end ? will django be extinct soon??</strong> Before coming to any conclusion, let us understand in what arena of web development we are living now!!</p><p>When the popularity of JS frameworks like Vue , Angular , and recently from 2018 , <strong>React.js </strong>starts to begin , popularity of <strong>component based web development</strong> started to fire (means you will create your backend logic in a separate framework , maybe of separate language based and frontend also in a separate framework , preferably under the JS giants and via <strong>REST API </strong>you have to connect them) . Thus it also pushed forward the reputation of <strong>Hybrid Web Development </strong>. Fastapi is serving this modularity from <strong>python-end</strong> along with some new features like <strong>Type Annotations , built-in API docs . </strong>But wait a minute !!…Django already have a popular third party REST API creating app throughout its journey — <strong>DjREST (Django REST Framework)</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/921/1*1AFYWR6FdJ-Q7kV1xxkrHA.png" /></figure><p><em>what made django different from others , also makes a clear difference in between DJREST and other REST creation providers</em> . In djrest , you will create an api in a <strong>part by part</strong> process , means you will create <strong>models for databases </strong>, write <strong>serializer </strong>(<em>the way how api formats the data while sending it from user to database or viceversa , the most common format is </em><strong><em>JSON</em></strong><em>)</em> <strong>logics</strong> and map those logics to various HTTP METHODS by <strong>View-classes. </strong>Yeah!!.. a little stressful it is to make Rest Apis in djrest but you will grab the fundamental processes of how REST API WORKS in reality.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*M1SS4yF-mYheMOWfXbnppw.jpeg" /><figcaption>SERIALIZATION logics — FARMERS API project</figcaption></figure><p>Although for this current scenario , <strong>microframeworks </strong>like flask has also started to rise again as from the birth time of django, it’s only focusing on creating REST APIs especially. So what ?….django has a new option — <strong>DJ-NINJA (NINJA API)</strong></p><p>Though , the reputation of DJREST is still skyhigh for creating strong backend based application , especially with <strong>react </strong>and <strong>flutter (mobile) , Dj-ninja </strong>is a very recently born REST provider third party microtool for django which is exactly the same in syntaxes and components like <strong>FastAPI. </strong><em>But it has arrived to solve the problems that was facing by fastapi while connecting to django ORM and some other ones.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/898/1*PfrZ4BBmCwFY9JnivVj5bQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/941/1*kyERLfukD-sZ2udiR6QgOQ.png" /><figcaption><strong>Django-ninja</strong> ( left ) and<strong> Fastapi </strong>( right )</figcaption></figure><p>Although django had anothe REST provider, <strong>testypie , </strong>which has no so much popularity in recent days. Else, django has many packadges to connect with other CSS frameworks like tailwind (search on google ‘Django-tailwind’) which pastes your complex logic to beautiful UI and python drivers to connect with NoSQL databases. <strong>So, you see evolution of django is constantly happening for which its journey is still ON , thats’s why many indutries(Youtube, spotify etc) use this framework . </strong>On the other hand ,frameworks like fast api has created a reason, why you should move to python for <strong>finest backend development. For this reason, the winner is everyone and their parent language PYTHON!!</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=87b12e8d13ae" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>