<?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"><channel><title><![CDATA[Dev.Junction]]></title><description><![CDATA[We talk about Web Development, Programming, JavaScript, Python, Freelancing and Career related tips. Learning is a never ending process, keep learning and follow DevJunction for more.]]></description><link>https://blog.devjunction.in</link><image><url>https://cdn.hashnode.com/res/hashnode/image/upload/v1651940925157/zpZiaSZ47.png</url><title>Dev.Junction</title><link>https://blog.devjunction.in</link></image><generator>RSS for Node</generator><lastBuildDate>Fri, 10 Apr 2026 13:21:01 GMT</lastBuildDate><atom:link href="https://blog.devjunction.in/rss.xml" rel="self" type="application/rss+xml"/><language><![CDATA[en]]></language><ttl>60</ttl><item><title><![CDATA[What is TypeScript, Why and how to use it?]]></title><description><![CDATA[You might have heard many senior JavaScript developers talking about typescript, and praising about the benefits of using it.
What is so special in TypeScript that it is being used by over 13.3M+ developer worldwide, as per GitHub statistics?
We will...]]></description><link>https://blog.devjunction.in/what-is-typescript-why-and-how-to-use-it</link><guid isPermaLink="true">https://blog.devjunction.in/what-is-typescript-why-and-how-to-use-it</guid><category><![CDATA[TypeScript]]></category><category><![CDATA[JavaScript]]></category><category><![CDATA[React]]></category><category><![CDATA[Frontend Development]]></category><category><![CDATA[Web Development]]></category><dc:creator><![CDATA[Gaurav Sharma]]></dc:creator><pubDate>Wed, 27 Sep 2023 15:08:02 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1695826878960/31264b94-2472-4d59-b8db-e3d157292bbc.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>You might have heard many senior JavaScript developers talking about typescript, and praising about the benefits of using it.</p>
<p>What is so special in TypeScript that it is being used by over 13.3M+ developer worldwide, as per GitHub statistics?</p>
<p>We will go through all the details of TypeScript in this blog series. I will write a small blog regularly in this series, and each blog will consist a small dose of TypeScript, which you can take on easily without getting overwhelmed of learning.</p>
<h1 id="heading-the-definition">The Definition:</h1>
<p>As per official website,</p>
<blockquote>
<p>TypeScript is a strongly typed programming language that builds on JavaScript, giving you better tooling at any scale.</p>
</blockquote>
<p>Do you remember the days when you were learning programming languages, and you got to know about C Programming, C++ and Java!</p>
<p>Well, if you have ever done programming in any one of these three programming language, you are already aware of data types.</p>
<p>Whenever you declare some variable, you used to specify the data type of that variable in C or C++ or Java.</p>
<p>These are strictly typed languages, you can not just define a variable like you do in JavaScript or Python, because Python &amp; JavaScript are considered dynamically typed languages which means, interpreter will figure out the type of variable on the fly and might change in runtime.</p>
<p>There are advantage of using dynamically typed languages like Python &amp; JavaScript, it gives you flexibility, and speed while writing code, you can focus on the solution rather than fixing a Type Error.</p>
<p>But this is not it, once your code start getting complex, you will face debugging related issues. Debugging becomes trickier in dynamically typed languages, sometimes the error is random.</p>
<p>This is when TypeScript came into picture, TypeScript is nothing but a superset of JavaScript, which has everything JavaScript consists of, but add the power of defining types in your JavaScript code.</p>
<h1 id="heading-why-typescript">Why TypeScript?</h1>
<p>Since the dawn of the Web, JavaScript is dominating the Web, you can not assume a dynamic website or a Web Application without JavaScript. So you can not change the whole programming language to introduce a typed programming language for web, hence, TypeScript was borne inside Microsoft.</p>
<p>Initially, they were using it internally as a tool on top of JavaScript to add static type and type annotation for large scale applications. TypeScript was first announced by Microsoft in October 2012, with Anders Hejlsberg, the creator of C# and Turbo Pascal, leading the project.</p>
<p>Typescript will not make your program faster, Typescript is meant for developers, it helps developer write clean and maintainable code.</p>
<p>TypeScript helps developer to avoid unintentional blind code, which is full of bugs and will start breaking once you run it in production.</p>
<p>Typescript is nothing but a <strong>syntactic sugar</strong> on top of JavaScript.</p>
<h1 id="heading-how-to-use-typescript">How to use TypeScript?</h1>
<p>Enough talk, we will see some code examples of TypeScript here. But before that I want to write some points which I feel important to know for any beginner.</p>
<ol>
<li><p>TypeScript is not compatible with browsers. You will write your code in <code>.ts</code> files and Typescript compiler will compile it into <code>.js</code> file which can be easily run in any browser.</p>
</li>
<li><p>To compile Typescript code, you have to download a compiler from <a target="_blank" href="https://www.typescriptlang.org/download">here</a>.</p>
</li>
<li><p>Any <code>.js</code> file can be run by Typescript, as Typescript is a superset of JavaScript, which means it is meant to be compatible with TypeScript.</p>
</li>
<li><p>In a <strong>Typescript project</strong>, you can import a JavaScript file into a Typescript file or vice versa. Both the cases are possible.</p>
</li>
</ol>
<p>Let’s see come JavaScript &amp; Typescript example and compare both codes:</p>
<pre><code class="lang-jsx"><span class="hljs-keyword">var</span> name = <span class="hljs-string">"Danger"</span>
<span class="hljs-built_in">console</span>.log(<span class="hljs-string">"Hello, "</span> + name)

name = <span class="hljs-number">234</span>
<span class="hljs-built_in">console</span>.log(name)
</code></pre>
<p>So in the above JavaScript code, you can reassign a value after assigning once, but in TypeScript it’s a bit different case:</p>
<pre><code class="lang-tsx">var name: string = "Danger"
console.log("Hello, " + name)
name = 234   // This line will throw error
console.log(name)
</code></pre>
<p>As you can see in the above TypeScript code, it will throw error on line no. 3, because first we have initialized the <code>name</code> variable with <code>string</code> using Typescript type annotation, but later we are assigning the number value to name, resulting your code into an error.</p>
<p>This was a basic type example of Typescript, in the next blogs we will get to know some more insights of TypeScript, like everyday types, interfaces, enums, mixins, generics, module augmentation and most importantly the usage of TypeScript into a React project.</p>
<blockquote>
<p>I hope you have learned something from this blog, write your thoughts in the comments as it will help me write better blogs in future.</p>
</blockquote>
<p><em>Happy Learning!</em></p>
<h3 id="heading-reference"><strong>Reference:</strong></h3>
<p><a target="_blank" href="https://www.typescriptlang.org/why-create-typescript">https://www.typescriptlang.org/why-create-typescript</a> <a target="_blank" href="https://www.typescriptlang.org/docs/">https://www.typescriptlang.org/docs/</a></p>
<p><a target="_blank" href="https://www.youtube.com/watch?v=DibH4GRRWQU&amp;pp=ygUVdHlwZXNjcmlwdCBjb25mZXJlbmNl">https://www.youtube.com/watch?v=DibH4GRRWQU&amp;pp=ygUVdHlwZXNjcmlwdCBjb25mZXJlbmNl</a></p>
<h3 id="heading-social-links"><strong>Social Links:</strong></h3>
<ul>
<li><p><a target="_blank" href="https://www.linkedin.com/in/mnamegaurav/"><strong>LinkedIn</strong></a></p>
</li>
<li><p><a target="_blank" href="https://blog.devjunction.in/"><strong>Blog</strong></a></p>
</li>
<li><p><a target="_blank" href="https://www.youtube.com/devjunction"><strong>YouTube</strong></a></p>
</li>
<li><p><a target="_blank" href="https://gaurav.devjunction.in/"><strong>Website</strong></a></p>
</li>
<li><p><a target="_blank" href="https://github.com/mnamegaurav"><strong>GitHub</strong></a></p>
</li>
</ul>
]]></content:encoded></item><item><title><![CDATA[Launching my E-book on Django Signals Demystified: A Step-by-Step Guide to Event-Driven Programming]]></title><description><![CDATA[Are you tired of tightly coupled code and struggling to keep track of events in your Django application? Look no further! Our new e-book, "Django Signals Demystified: A Step-by-Step Guide to Event-Driven Programming" is here to help you master the po...]]></description><link>https://blog.devjunction.in/launching-my-e-book-on-django-signals-demystified-a-step-by-step-guide-to-event-driven-programming</link><guid isPermaLink="true">https://blog.devjunction.in/launching-my-e-book-on-django-signals-demystified-a-step-by-step-guide-to-event-driven-programming</guid><category><![CDATA[Django]]></category><category><![CDATA[Python]]></category><category><![CDATA[software development]]></category><category><![CDATA[Web Development]]></category><category><![CDATA[webdev]]></category><dc:creator><![CDATA[Gaurav Sharma]]></dc:creator><pubDate>Tue, 17 Jan 2023 04:51:04 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1673930966549/8c5e4bb1-dfb2-4815-8ff1-d233de18698e.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Are you tired of tightly coupled code and struggling to keep track of events in your Django application? Look no further! Our new e-book, "<strong><em>Django Signals Demystified: A Step-by-Step Guide to Event-Driven Programming</em></strong>" is here to help you master the powerful signal feature in Django.</p>
<p>With clear explanations and practical examples, this e-book is the perfect resource for developers looking to build more robust and maintainable applications. You'll learn about the built-in signals that Django provides, and how to use them to perform actions such as validating data or sending notifications. You'll also learn how to create your own custom signals, with a step-by-step guide and a real-world example.</p>
<p>Our e-book also covers the synchronous nature of signals, and how to use Celery to make signals asynchronous, allowing you to improve the performance of your application. Whether you're a beginner or an experienced developer, this e-book will give you the knowledge and skills you need to unlock the full potential of Django signals.</p>
<p>Don't let tightly coupled code and poor event management hold you back any longer. Get your copy of "<strong><em>Django Signals Demystified: A Step-by-Step Guide to Event-Driven Programming</em></strong>" today and take your Django development to the next level!</p>
<p><strong>This is what you will get inside the e-book:</strong></p>
<ul>
<li><p>Analogy of Django Signals</p>
<ul>
<li><p>Fire Alarm System</p>
</li>
<li><p>Traffic Signals</p>
</li>
</ul>
</li>
<li><p>What is a Signal in Django?</p>
<ul>
<li>A Basic Example</li>
</ul>
</li>
<li><p>A Step-by-Step guide for using Django signals</p>
<ul>
<li>Notifying the admin user (Example-1)</li>
</ul>
</li>
<li><p>Builtin Django Signals</p>
</li>
<li><p>Tracking the Price of products with Django Signals (Example-2)</p>
</li>
<li><p>Creating custom Signals in Django</p>
</li>
<li><p>Synchronous nature of Signals</p>
</li>
<li><p>Handling Asynchronous tasks with Signals (Example-3)</p>
</li>
<li><p>Pros and Cons of Signals</p>
</li>
<li><p>Conclusion</p>
</li>
</ul>
<p>Get your FREE copy here: <a target="_blank" href="https://store.devjunction.in/l/django-signals-demystified/SIGNAL23">https://store.devjunction.in/l/django-signals-demystified/SIGNAL23</a></p>
<p><em>HURRY UP, IT IS FREE FOR A LIMITED NUMBER OF PEOPLE.</em></p>
<p>Want to check out my other e-books? <a target="_blank" href="https://store.devjunction.in/">Check it out here</a>.</p>
<p><strong><em>Any thoughts? Write it down in the comments.</em></strong></p>
<blockquote>
<p><strong><em>For more such crispy blogs daily, follow Dev.Junction, subscribe to our newsletter and get notified daily.</em></strong></p>
</blockquote>
<h3 id="heading-social-links"><strong>Social Links:</strong></h3>
<ul>
<li><p><a target="_blank" href="https://www.linkedin.com/in/mnamegaurav/"><strong>LinkedIn</strong></a></p>
</li>
<li><p><a target="_blank" href="https://blog.devjunction.in/"><strong>Blog</strong></a></p>
</li>
<li><p><a target="_blank" href="https://store.devjunction.in/">E-Books</a></p>
</li>
<li><p><a target="_blank" href="https://www.youtube.com/devjunction"><strong>YouTube</strong></a></p>
</li>
<li><p><a target="_blank" href="https://gaurav.devjunction.in/"><strong>Website</strong></a></p>
</li>
<li><p><a target="_blank" href="https://github.com/mnamegaurav"><strong>GitHub</strong></a></p>
</li>
<li><p><a target="_blank" href="https://www.instagram.com/mnamegaurav/"><strong>Instagram</strong></a></p>
</li>
<li><p><a target="_blank" href="https://twitter.com/mnamegaurav"><strong>Twitter</strong></a></p>
</li>
</ul>
]]></content:encoded></item><item><title><![CDATA[Optimizing Database Queries in Django: A Guide to select_related and prefetch_related]]></title><description><![CDATA[In Django, select_related and prefetch_related are two functions that can be used to optimize database queries. They are particularly useful when working with foreign keys and many-to-many relationships, as they allow you to retrieve related objects ...]]></description><link>https://blog.devjunction.in/optimizing-database-queries-in-django-a-guide-to-selectrelated-and-prefetchrelated</link><guid isPermaLink="true">https://blog.devjunction.in/optimizing-database-queries-in-django-a-guide-to-selectrelated-and-prefetchrelated</guid><category><![CDATA[Django]]></category><category><![CDATA[Python]]></category><category><![CDATA[Python 3]]></category><category><![CDATA[Web Development]]></category><category><![CDATA[Databases]]></category><dc:creator><![CDATA[Gaurav Sharma]]></dc:creator><pubDate>Wed, 11 Jan 2023 15:14:24 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1673449973193/cf867305-4f8c-4f3e-b87c-a43e804ee133.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>In Django, <code>select_related</code> and <code>prefetch_related</code> are two functions that can be used to optimize database queries. They are particularly useful when working with foreign keys and many-to-many relationships, as they allow you to retrieve related objects in a single query, rather than making separate queries for each object.</p>
<h3 id="heading-the-selectrelated">The <code>select_related</code>:</h3>
<p><code>select_related</code> is used to retrieve related objects in a single <code>SELECT</code> statement. It works by following foreign keys and many-to-many relationships and including the related objects in the initial query.</p>
<p>For example:</p>
<pre><code class="lang-python"><span class="hljs-keyword">from</span> django.db <span class="hljs-keyword">import</span> models

<span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">Author</span>(<span class="hljs-params">models.Model</span>):</span>
    name = models.CharField(max_length=<span class="hljs-number">50</span>)

<span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">Book</span>(<span class="hljs-params">models.Model</span>):</span>
    title = models.CharField(max_length=<span class="hljs-number">50</span>)
    author = models.ForeignKey(Author, on_delete=models.CASCADE)

<span class="hljs-comment"># Without select_related</span>
authors = Author.objects.all()
<span class="hljs-keyword">for</span> author <span class="hljs-keyword">in</span> authors:
    books = author.book_set.all()

<span class="hljs-comment"># With select_related</span>
authors = Author.objects.all().select_related(<span class="hljs-string">'book'</span>)
<span class="hljs-keyword">for</span> author <span class="hljs-keyword">in</span> authors:
    books = author.book_set.all()
</code></pre>
<p>In the example above, without <code>select_related</code>, a separate database query would be made for each <code>author</code> object to retrieve the related <code>book</code> objects. With <code>select_related</code>, all the related objects are included in the initial query, improving the performance of the code.</p>
<h3 id="heading-the-prefetchrelated">The <code>prefetch_related</code>:</h3>
<p><code>prefetch_related</code> is similar to <code>select_related</code>, but it is used to prefetch related objects for a Queryset in a single query, rather than retrieving them when the object is accessed.</p>
<p>For example:</p>
<pre><code class="lang-python"><span class="hljs-comment"># Without prefetch_related</span>
authors = Author.objects.all()
<span class="hljs-keyword">for</span> author <span class="hljs-keyword">in</span> authors:
    books = author.book_set.all()

<span class="hljs-comment"># With prefetch_related</span>
authors = Author.objects.all().prefetch_related(<span class="hljs-string">'book'</span>)
<span class="hljs-keyword">for</span> author <span class="hljs-keyword">in</span> authors:
    books = author.book_set.all()
</code></pre>
<p>In the example above, without <code>prefetch_related</code>, a separate query would be made for each <code>author</code> object to retrieve the related <code>book</code> objects. With <code>prefetch_related</code>, the related objects are prefetched in a single query, improving the performance of the code.</p>
<h3 id="heading-conclusion">Conclusion:</h3>
<p>So the conclusion is that <code>select_related</code> and <code>prefetch_related</code> can be used together to optimize database queries and improve the performance of your Django application.</p>
<p><strong><em>Any thoughts? Write it down in the comments.</em></strong></p>
<blockquote>
<p>For more such crispy blogs daily, follow Dev.Junction, subscribe to our newsletter and get notified daily.</p>
</blockquote>
<h3 id="heading-social-links"><strong>Social Links:</strong></h3>
<ul>
<li><p><a target="_blank" href="https://www.linkedin.com/in/mnamegaurav/"><strong>LinkedIn</strong></a></p>
</li>
<li><p><a target="_blank" href="https://blog.devjunction.in/"><strong>Blog</strong></a></p>
</li>
<li><p><a target="_blank" href="https://www.youtube.com/devjunction"><strong>YouTube</strong></a></p>
</li>
<li><p><a target="_blank" href="https://gaurav.devjunction.in/"><strong>Website</strong></a></p>
</li>
<li><p><a target="_blank" href="https://github.com/mnamegaurav"><strong>GitHub</strong></a></p>
</li>
<li><p><a target="_blank" href="https://www.instagram.com/mnamegaurav/"><strong>Instagram</strong></a></p>
</li>
<li><p><a target="_blank" href="https://twitter.com/mnamegaurav"><strong>Twitter</strong></a></p>
</li>
</ul>
]]></content:encoded></item><item><title><![CDATA[I lost INR 500K because of these mistakes in just 6 months:]]></title><description><![CDATA[2022 was not a good year financially because I did so many mistakes knowingly or unknowingly that, eventually, made me lose INR 500K over the course of just 6 months.
So here are those mistakes which taught me about freelancing, finance management et...]]></description><link>https://blog.devjunction.in/i-lost-inr-500k-because-of-these-mistakes-in-just-6-months</link><guid isPermaLink="true">https://blog.devjunction.in/i-lost-inr-500k-because-of-these-mistakes-in-just-6-months</guid><category><![CDATA[Web Development]]></category><category><![CDATA[Freelancing]]></category><category><![CDATA[webdev]]></category><category><![CDATA[software development]]></category><category><![CDATA[Software Engineering]]></category><dc:creator><![CDATA[Gaurav Sharma]]></dc:creator><pubDate>Tue, 10 Jan 2023 06:07:49 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1673331674999/076305ce-06b5-4e59-ae83-1e800c212853.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>2022 was not a good year financially because I did so many mistakes knowingly or unknowingly that, eventually, made me lose INR 500K over the course of just 6 months.</p>
<p>So here are those mistakes which taught me about freelancing, finance management etc.</p>
<h3 id="heading-not-having-watertight-contracts-with-clients"><strong>Not having watertight contracts with clients:</strong></h3>
<p>If you are at a level where you are taking large-scale projects as an individual freelancer, then you better make sure that your contracts are not those basic and simple contracts that a person can exploit easily. Always do a formal contract, which is not easy to exploit. You can consult your lawyer or get an online template for a water-tight contract. Otherwise, the result of a loose contract can really hit you financially, the client can deny paying you any money and all your month's work will be just wasted in seconds.</p>
<h3 id="heading-taking-decisions-emotionally-not-logically"><strong>Taking decisions emotionally, not logically:</strong></h3>
<p>Sometimes you feel like buying that iPhone or buying those 10k branded shoes, and you did it because you felt like doing it. If you are ever in a situation like this, ask yourself, do you have 4x the cost of that purchase? If the answer is NO, then don't do it. And even if the answer is YES, reconsider other factors such as whether it is worthwhile to buy such expensive stuff, how it is going to affect your upcoming months, whether it is going to make an impact in your life etc.</p>
<h3 id="heading-chasing-money-but-excellence"><strong>Chasing money but excellence:</strong></h3>
<p>Once Ranchoddas said, "Always follow excellence, success will chase you". Stop chasing the money, rather become skillful, be a better version of yourself from the previous one, learn new things, and focus on providing better value out of your skills. Trust me, it will take some time, but eventually, money will start following you. But for now, focus on being skillful and valuable.</p>
<h3 id="heading-taking-loans">Taking loans:</h3>
<p>Taking a loan is NOT a bad thing if you are really in need of some urgent money, but I suggest you always avoid it, as with time you will become habitual of taking loans and in the end you have to pay back with a large sum of interest.</p>
<h3 id="heading-selling-stuff-to-fulfill-your-desires">Selling stuff to fulfill your desires:</h3>
<p>Well when you have taken a lot of loans, and now you have to maintain your lifestyle and fulfill your desires, you can not show yourself as poor and needy. You will start thinking of selling your expensive stuff to maintain that lifestyle, <strong>NEVER EVER DO THAT</strong>. Again it is a bad habit to sell stuff just to fulfill your desires, take some time, and use your skills to make money, but do not ever sell your stuff to fulfill your desires.</p>
<p>Here I am standing and fighting with tough times, I took bad decisions and that time has already passed away.</p>
<p>Hope you will avoid these mistakes the best you can, keep learning, and keep growing. ✌️</p>
<p>Also, this is my humble request, if someone in your network is looking for a freelancer developer who can work on a long-term basis, I am the guy you can consider. My contact details are given below, I am available anytime.</p>
<h3 id="heading-contact-me">Contact Me:</h3>
<ul>
<li><p><a target="_blank" href="https://www.linkedin.com/in/mnamegaurav/"><strong>LinkedIn</strong></a></p>
</li>
<li><p>Email: gaurav91297@gmail.com</p>
</li>
<li><p><a target="_blank" href="https://t.me/mnamegaurav">Telegram</a></p>
</li>
</ul>
<h3 id="heading-social-links"><strong>Social Links:</strong></h3>
<ul>
<li><p><a target="_blank" href="https://www.linkedin.com/in/mnamegaurav/"><strong>LinkedIn</strong></a></p>
</li>
<li><p><a target="_blank" href="https://blog.devjunction.in/"><strong>Blog</strong></a></p>
</li>
<li><p><a target="_blank" href="https://www.youtube.com/devjunction"><strong>YouTube</strong></a></p>
</li>
<li><p><a target="_blank" href="https://gaurav.devjunction.in/"><strong>Website</strong></a></p>
</li>
<li><p><a target="_blank" href="https://github.com/mnamegaurav"><strong>GitHub</strong></a></p>
</li>
<li><p><a target="_blank" href="https://www.instagram.com/mnamegaurav/"><strong>Instagram</strong></a></p>
</li>
<li><p><a target="_blank" href="https://twitter.com/mnamegaurav"><strong>Twitter</strong></a></p>
</li>
</ul>
]]></content:encoded></item><item><title><![CDATA[5 Tips for Optimizing Performance in a React App]]></title><description><![CDATA[Introduction:
If you're building a React application, it's important to ensure that it performs well and provides a smooth user experience.
In this article, we'll cover 5 tips for optimizing performance in a React app. From optimizing your component ...]]></description><link>https://blog.devjunction.in/5-tips-for-optimizing-performance-in-a-react-app</link><guid isPermaLink="true">https://blog.devjunction.in/5-tips-for-optimizing-performance-in-a-react-app</guid><category><![CDATA[Web Development]]></category><category><![CDATA[React]]></category><category><![CDATA[React Native]]></category><category><![CDATA[JavaScript]]></category><category><![CDATA[webdev]]></category><dc:creator><![CDATA[Gaurav Sharma]]></dc:creator><pubDate>Thu, 05 Jan 2023 11:05:11 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1672916554909/50cd5ca5-2a1b-4ffa-a704-c283e3a90390.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<h3 id="heading-introduction">Introduction:</h3>
<p>If you're building a React application, it's important to ensure that it performs well and provides a smooth user experience.</p>
<p>In this article, we'll cover 5 tips for optimizing performance in a React app. From optimizing your component rendering to minimizing the number of DOM elements, these tips will help you build a faster and more efficient React application.</p>
<p>Let’s get started:</p>
<ol>
<li><p>Use the React Developer Tools: You can use the React Developer Tools browser extension to inspect the components and performance of your React app. Here's how to install it:</p>
<pre><code class="lang-bash"> npm install -g react-devtools
</code></pre>
</li>
<li><p>Use the <code>React.memo()</code> higher-order component: The <code>React.memo()</code> higher-order component is a performance optimization tool that allows you to prevent unnecessary re-renders of functional components. Here's an example of how to use it:</p>
<pre><code class="lang-jsx"> <span class="hljs-keyword">import</span> React <span class="hljs-keyword">from</span> <span class="hljs-string">'react'</span>;

 <span class="hljs-keyword">const</span> MyComponent = <span class="hljs-function">(<span class="hljs-params">{ name }</span>) =&gt;</span> {
   <span class="hljs-keyword">return</span> <span class="xml"><span class="hljs-tag">&lt;<span class="hljs-name">div</span>&gt;</span>{name}<span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span></span>;
 };

 <span class="hljs-keyword">export</span> <span class="hljs-keyword">default</span> React.memo(MyComponent);
</code></pre>
<p> <code>React.memo</code> HOC will perform a shallow comparison of the props to determine if the component should re-render. However, you can provide a <code>compare</code> function as a second argument to the <code>React.memo</code> HOC to customize the prop comparison.</p>
</li>
<li><p>Use the <code>useMemo()</code> and <code>useCallback()</code> hooks: The <code>useMemo()</code> and <code>useCallback()</code> hooks are performance optimization tools that allow you to memoize values and functions in your React components. Here's an example of how to use them:</p>
<pre><code class="lang-jsx"> <span class="hljs-keyword">import</span> { useMemo, useCallback } <span class="hljs-keyword">from</span> <span class="hljs-string">'react'</span>;

 <span class="hljs-keyword">const</span> MyComponent = <span class="hljs-function">(<span class="hljs-params">{ data }</span>) =&gt;</span> {
   <span class="hljs-keyword">const</span> memoizedValue = useMemo(<span class="hljs-function">() =&gt;</span> {
     <span class="hljs-comment">// Expensive computation goes here</span>
     <span class="hljs-keyword">return</span> expensiveComputation(data);
   }, [data]);

   <span class="hljs-keyword">const</span> memoizedCallback = useCallback(<span class="hljs-function">() =&gt;</span> {
     <span class="hljs-comment">// Expensive function goes here</span>
     <span class="hljs-keyword">return</span> expensiveFunction(data);
   }, [data]);

   <span class="hljs-keyword">return</span> (
     <span class="xml"><span class="hljs-tag">&lt;<span class="hljs-name">div</span>&gt;</span>
       <span class="hljs-tag">&lt;<span class="hljs-name">div</span>&gt;</span>{memoizedValue}<span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span>
       <span class="hljs-tag">&lt;<span class="hljs-name">button</span> <span class="hljs-attr">onClick</span>=<span class="hljs-string">{memoizedCallback}</span>&gt;</span>Click me<span class="hljs-tag">&lt;/<span class="hljs-name">button</span>&gt;</span>
     <span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span></span>
   );
 };

 <span class="hljs-keyword">export</span> <span class="hljs-keyword">default</span> MyComponent;
</code></pre>
</li>
<li><p>Use the <code>React.lazy()</code> and Suspense components: The <code>React.lazy()</code> and Suspense components are tools that allow you to lazy-load components and improve the performance of your app by only loading the components that are needed at a given time. Here's an example of how to use them:</p>
<pre><code class="lang-jsx"> <span class="hljs-keyword">import</span> React, { Suspense } <span class="hljs-keyword">from</span> <span class="hljs-string">'react'</span>;

 <span class="hljs-keyword">const</span> LazyComponent = React.lazy(<span class="hljs-function">() =&gt;</span> <span class="hljs-keyword">import</span>(<span class="hljs-string">'./LazyComponent'</span>));

 <span class="hljs-keyword">const</span> MyComponent = <span class="hljs-function">() =&gt;</span> {
   <span class="hljs-keyword">return</span> (
     <span class="xml"><span class="hljs-tag">&lt;<span class="hljs-name">Suspense</span> <span class="hljs-attr">fallback</span>=<span class="hljs-string">{</span>&lt;<span class="hljs-attr">div</span>&gt;</span>Loading...<span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span>}&gt;
       <span class="hljs-tag">&lt;<span class="hljs-name">LazyComponent</span> /&gt;</span>
     <span class="hljs-tag">&lt;/<span class="hljs-name">Suspense</span>&gt;</span></span>
   );
 };

 <span class="hljs-keyword">export</span> <span class="hljs-keyword">default</span> MyComponent;
</code></pre>
</li>
<li><p>React Context is a way to pass data through the component tree without having to pass props down manually at every level. It can be an effective way to optimize your React app by reducing the number of prop updates that occur.</p>
<p> Here's an example of how you can create a context in your React app:</p>
<pre><code class="lang-jsx"> <span class="hljs-keyword">import</span> { createContext } <span class="hljs-keyword">from</span> <span class="hljs-string">'react'</span>

 <span class="hljs-keyword">const</span> MyContext = createContext()
</code></pre>
<p> To provide a value for the context, you can use the <code>MyContext.Provider</code> component:</p>
<pre><code class="lang-jsx"> <span class="hljs-keyword">import</span> { createContext } <span class="hljs-keyword">from</span> <span class="hljs-string">'react'</span>

 <span class="hljs-keyword">const</span> MyContext = createContext()

 <span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">App</span>(<span class="hljs-params"></span>) </span>{
   <span class="hljs-keyword">return</span> (
     <span class="xml"><span class="hljs-tag">&lt;<span class="hljs-name">MyContext.Provider</span> <span class="hljs-attr">value</span>=<span class="hljs-string">"my value"</span>&gt;</span>
       <span class="hljs-tag">&lt;<span class="hljs-name">MyComponent</span> /&gt;</span>
     <span class="hljs-tag">&lt;/<span class="hljs-name">MyContext.Provider</span>&gt;</span></span>
   )
 }
</code></pre>
<p> Then, to consume the context value in a component, you can use the <code>useContext</code> hook:</p>
<pre><code class="lang-jsx"> <span class="hljs-keyword">import</span> { useContext } <span class="hljs-keyword">from</span> <span class="hljs-string">'react'</span>

 <span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">MyComponent</span>(<span class="hljs-params"></span>) </span>{
   <span class="hljs-keyword">const</span> contextValue = useContext(MyContext)

   <span class="hljs-keyword">return</span> (
     <span class="xml"><span class="hljs-tag">&lt;<span class="hljs-name">div</span>&gt;</span>{contextValue}<span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span></span>
   )
 }
</code></pre>
<p> By using context, you can avoid having to pass props down through multiple levels of the component tree, which can help to optimize your app by reducing the number of prop updates that occur.</p>
</li>
</ol>
<h3 id="heading-conclusion">Conclusion:</h3>
<p>By following these steps and using the tools and techniques described above, you can optimize the performance of your React app and improve the user experience.</p>
<p>Keep in mind that performance optimization is a continuous process, and it's important to regularly measure and analyze the performance of your app to identify any issues and address them accordingly.</p>
<p><strong><em>Any thoughts? Write it down in the comments.</em></strong></p>
<blockquote>
<p>For more such crispy blogs daily, follow Dev.Junction, subscribe to our newsletter and get notified daily.</p>
</blockquote>
<h2 id="heading-social-links"><strong>Social Links</strong></h2>
<ul>
<li><p><a target="_blank" href="https://www.linkedin.com/in/mnamegaurav/">LinkedIn</a>: <a target="_blank" href="http://linkedin.com/in/mnamegaurav">linkedin.com/in/mnamegaurav</a></p>
</li>
<li><p><a target="_blank" href="https://blog.devjunction.in">Blog</a>: <a target="_blank" href="https://blog.devjunction.in">blog.devjunction.in</a></p>
</li>
<li><p><a target="_blank" href="https://www.youtube.com/devjunction">YouTube</a>: <a target="_blank" href="http://youtube.com/devjunction">youtube.com/devjunction</a></p>
</li>
<li><p><a target="_blank" href="https://gaurav.devjunction.in/">Website</a>: <a target="_blank" href="http://gaurav.devjunction.in/">gaurav.devjunction.in</a></p>
</li>
<li><p><a target="_blank" href="https://github.com/mnamegaurav">GitHub</a>: <a target="_blank" href="http://github.com/mnamegaurav">github.com/mnamegaurav</a></p>
</li>
<li><p><a target="_blank" href="https://www.instagram.com/mnamegaurav/">Instagram</a>: <a target="_blank" href="http://instagram.com/mnamegaurav">instagram.com/mnamegaurav</a></p>
</li>
<li><p><a target="_blank" href="https://twitter.com/mnamegaurav"><strong>Twitter</strong></a><strong>:</strong> <a target="_blank" href="http://twitter.com/mnamegaurav"><strong>twitter.com/mnamegaurav</strong></a></p>
</li>
</ul>
]]></content:encoded></item><item><title><![CDATA[5 Common Restful API Anti-Patterns and How to Avoid Them]]></title><description><![CDATA[Introduction:
Restful APIs (Representational State Transfer APIs) are designed to be easy to use and understand and are a common choice for building web services. However, like any software design pattern, certain antipatterns can lead to problems if...]]></description><link>https://blog.devjunction.in/5-common-restful-api-anti-patterns-and-how-to-avoid-them</link><guid isPermaLink="true">https://blog.devjunction.in/5-common-restful-api-anti-patterns-and-how-to-avoid-them</guid><category><![CDATA[APIs]]></category><category><![CDATA[REST API]]></category><category><![CDATA[Web Development]]></category><category><![CDATA[webdev]]></category><category><![CDATA[software development]]></category><dc:creator><![CDATA[Gaurav Sharma]]></dc:creator><pubDate>Sun, 01 Jan 2023 04:38:37 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1672634064368/fadd096a-1129-4517-9010-300833dd5b4d.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<h3 id="heading-introduction">Introduction:</h3>
<p>Restful APIs (Representational State Transfer APIs) are designed to be easy to use and understand and are a common choice for building web services. However, like any software design pattern, certain antipatterns can lead to problems if not avoided.</p>
<p>Here are some common Restful API antipatterns:</p>
<ol>
<li><p><strong>Tight coupling:</strong> Tightly coupling the client and the server can make the API inflexible and difficult to change. It's important to design the API in a way that decouples the client from the server so that changes to one do not affect the other.</p>
</li>
<li><p><strong>Lack of versioning:</strong> Not versioning your API can lead to issues when you need to make breaking changes to the API. It's important to version your API so that you can maintain backward compatibility and avoid breaking existing clients.</p>
</li>
<li><p><strong>Inadequate documentation:</strong> Poorly documented APIs can be difficult to use and lead to confusion for developers. It's important to provide clear and concise documentation for your API, including examples and explanations of each endpoint and its parameters.</p>
</li>
<li><p><strong>Overloading HTTP methods:</strong> HTTP methods like GET, POST, PUT, and DELETE are meant to convey the intended action of a request. Overloading these methods, or using them in a way that doesn't match their intended purpose, can make the API confusing and difficult to understand.</p>
</li>
<li><p><strong>Lack of error handling:</strong> Failing to handle errors properly can lead to confusing and frustrating experiences for developers using your API. It's important to provide clear error messages and appropriate HTTP status codes to help developers understand and debug any issues that may arise.</p>
</li>
</ol>
<h3 id="heading-conclusion">Conclusion:</h3>
<p>Avoiding these antipatterns can help ensure that your Restful API is easy to use, maintainable, and scalable. It's important to carefully design and document your API to ensure that it meets the needs of your users and is as effective as possible.</p>
<p><strong><em>Any thoughts? Write it down in the comments.</em></strong></p>
<blockquote>
<p><strong><em>For more such crispy blogs daily, follow Dev.Junction, subscribe to our newsletter and get notified daily.</em></strong></p>
</blockquote>
<h2 id="heading-social-links"><strong>Social Links</strong></h2>
<ul>
<li><p><a target="_blank" href="https://www.linkedin.com/in/mnamegaurav/"><strong>LinkedIn</strong></a><strong>:</strong> <a target="_blank" href="http://linkedin.com/in/mnamegaurav"><strong>linkedin.com/in/mnamegaurav</strong></a></p>
</li>
<li><p><a target="_blank" href="https://www.youtube.com/devjunction"><strong>YouTube</strong></a><strong>:</strong> <a target="_blank" href="http://youtube.com/devjunction"><strong>youtube.com/devjunction</strong></a></p>
</li>
<li><p><a target="_blank" href="https://gaurav.devjunction.in/"><strong>Website</strong></a><strong>:</strong> <a target="_blank" href="http://gaurav.devjunction.in"><strong>gaurav.devjunction.in</strong></a></p>
</li>
<li><p><a target="_blank" href="https://github.com/mnamegaurav"><strong>GitHub</strong></a><strong>:</strong> <a target="_blank" href="http://github.com/mnamegaurav"><strong>github.com/mnamegaurav</strong></a></p>
</li>
<li><p><a target="_blank" href="https://www.instagram.com/mnamegaurav/"><strong>Instagram</strong></a><strong>:</strong> <a target="_blank" href="http://instagram.com/mnamegaurav"><strong>instagram.com/mnamegaurav</strong></a></p>
</li>
<li><p><a target="_blank" href="https://twitter.com/mnamegaurav"><strong>Twitter</strong></a><strong>:</strong> <a target="_blank" href="http://twitter.com/mnamegaurav"><strong>twitter.com/mnamegaurav</strong></a></p>
</li>
</ul>
]]></content:encoded></item><item><title><![CDATA[10 Common Django Interview Questions and Answers]]></title><description><![CDATA[Introduction:
If you're preparing for a job interview that involves Django, it's important to be well-prepared and have a solid understanding of the framework. In this article, we'll cover 10 common Django interview questions that you may encounter, ...]]></description><link>https://blog.devjunction.in/10-common-django-interview-questions-and-answers</link><guid isPermaLink="true">https://blog.devjunction.in/10-common-django-interview-questions-and-answers</guid><category><![CDATA[Django]]></category><category><![CDATA[Python]]></category><category><![CDATA[Python 3]]></category><category><![CDATA[Web Development]]></category><category><![CDATA[webdev]]></category><dc:creator><![CDATA[Gaurav Sharma]]></dc:creator><pubDate>Sat, 31 Dec 2022 00:30:42 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1672232353774/492f37ae-3fdd-4a79-84bf-d9cf045e142e.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<h1 id="heading-introduction">Introduction:</h1>
<p>If you're preparing for a job interview that involves Django, it's important to be well-prepared and have a solid understanding of the framework. In this article, we'll cover 10 common Django interview questions that you may encounter, along with detailed answers to help you feel confident and prepared for your interview.</p>
<p>Whether you're a beginner or an experienced Django developer, this article is a great resource to help you brush up on your knowledge of the framework. We'll cover a range of topics. So let's get started!</p>
<h3 id="heading-q1">Q1:</h3>
<p><strong>What is Django, and what are some of its key features?</strong></p>
<p>Django is a high-level Python web framework that encourages rapid development and clean, pragmatic design. Some of its key features include:</p>
<ul>
<li><p>A powerful ORM (Object-Relational Mapper) for working with databases</p>
</li>
<li><p>A template engine for creating HTML, XML, or other markup languages</p>
</li>
<li><p>A routing system for mapping URLs to views</p>
</li>
<li><p>A form handling system for processing HTTP requests</p>
</li>
<li><p>An internationalization system for supporting multiple languages</p>
</li>
<li><p>Support for middleware, which allows developers to hook into the request-response cycle</p>
</li>
</ul>
<h3 id="heading-q2">Q2:</h3>
<p><strong>How does Django compare to other web frameworks, such as Flask or Ruby on Rails?</strong></p>
<p>Django and Flask are both popular web frameworks for Python, but they have some key differences. Django is a full-featured web framework that includes everything you need to build a complete web application, whereas Flask is a microframework that is designed to be flexible and extensible. Django is also more opinionated than Flask, which means it comes with a set of conventions and best practices that developers are expected to follow.</p>
<p>Ruby on Rails is another popular web framework, but it is written in Ruby rather than Python. Like Django, Rails is a full-featured web framework that includes everything you need to build a complete web application. One of the key differences between Django and Rails is the way they handle database relationships. Django uses a declarative syntax for defining relationships between models, whereas Rails uses an imperative syntax.</p>
<h3 id="heading-q3">Q3:</h3>
<p><strong>How does Django handle database transactions, and how does it ensure data integrity?</strong></p>
<p>Django supports database transactions, which allow developers to ensure that a series of database operations are either all completed or all rolled back if an error occurs. Django also uses a technique called "optimistic locking" to ensure data integrity when multiple users are interacting with the same data. When a user makes a change to a piece of data, Django checks to see if any other users have made changes to the same data since the user's copy was last updated. If there have been no changes, the user's changes are saved to the database. If there have been changes, Django raises a transaction error and the user's changes are not saved.</p>
<h3 id="heading-q4">Q4:</h3>
<p><strong>How does Django handle security, and what are some best practices for securing a Django application?</strong></p>
<p>Django includes a number of security features to help developers build secure applications, including:</p>
<ul>
<li><p>Input validation: Django automatically escapes HTML, JavaScript, and other special characters in user input to prevent cross-site scripting (XSS) attacks.</p>
</li>
<li><p>Cross-site request forgery (CSRF) protection: Django includes a CSRF protection middleware that verifies that requests are coming from the same site.</p>
</li>
<li><p>SQL injection protection: Django's ORM automatically escapes special characters in database queries to prevent SQL injection attacks.</p>
</li>
</ul>
<p>Some best practices for securing a Django application include:</p>
<ul>
<li><p>Using HTTPS for all traffic to protect against man-in-the-middle attacks</p>
</li>
<li><p>Regularly updating Django and any third-party libraries to ensure that the latest security fixes are applied</p>
</li>
<li><p>Using Django's built-in authentication system and avoiding rolling your own authentication code</p>
</li>
<li><p>Implementing access controls to ensure that users can only perform actions that they are authorized to do</p>
</li>
</ul>
<h3 id="heading-q5">Q5:</h3>
<p><strong>How does Django handle user authentication and authorization?</strong></p>
<p>Django includes a built-in authentication system that handles user registration, login, logout, and password management. The authentication system uses Django's ORM to store user information in the database</p>
<h3 id="heading-q6">Q6:</h3>
<p><strong>How does Django handle static files, and what are some best practices for serving static files in a Django application?</strong></p>
<p>Django has a built-in system for handling static files, such as CSS, JavaScript, and images. Developers can use Django's staticfiles app to manage static files and serve them to the client. By default, Django serves static files from a folder called "static" in the project root.</p>
<p>Some best practices for serving static files in a Django application include:</p>
<ul>
<li><p>Using a CDN (Content Delivery Network) to serve static files, which can improve performance and reduce the load on the server</p>
</li>
<li><p>Using versioned file names, such as "style.v1.css", to ensure that users' browsers always load the latest version of the file</p>
</li>
<li><p>Minimizing the number of static files by combining and minifying them where possible</p>
</li>
</ul>
<h3 id="heading-q7">Q7:</h3>
<p><strong>How does Django handle forms, and how can you customize form validation?</strong></p>
<p>Django has a built-in system for handling forms, which allows developers to create and validate form data. To create a form, developers define a form class in Python, which is then rendered as an HTML form in the template. To validate form data, developers can use Django's built-in form validation or create custom validation logic.</p>
<p>To customize form validation, developers can override the form's clean() method, which is called when the form is submitted. The clean() method can perform additional validation on the form data and raise a ValidationError if the data is invalid. Developers can also define custom form fields and widgets to further customize the form.</p>
<h3 id="heading-q8">Q8:</h3>
<p><strong>How does Django handle templates, and what are some best practices for designing templates?</strong></p>
<p>Django uses a template engine to render HTML templates with dynamic data. Developers can use Django's template language to define templates, which can include variables, loops, and other logic. To render a template, developers pass it a context, which is a dictionary of data that is used to populate the template.</p>
<p>Some best practices for designing templates include:</p>
<ul>
<li><p>Keeping templates as simple as possible and moving complex logic to the view function or to custom template tags and filters</p>
</li>
<li><p>Using Django's template inheritance feature to avoid repeating code in multiple templates</p>
</li>
<li><p>Avoiding using template logic to perform tasks that can be done more efficiently in the view function or in the database</p>
</li>
</ul>
<h3 id="heading-q9">Q9:</h3>
<p><strong>How does Django handle internationalization and localization?</strong></p>
<p>Django has built-in support for internationalization (i18n) and localization (l10n), which allows developers to build applications that can be easily translated into multiple languages. To enable internationalization in a Django application, developers need to set up the Django translation system and create translation files for each language they want to support. To localize an application, developers can use Django's template language to specify which text should be translated and can use the gettext library to translate strings in Python code.</p>
<h3 id="heading-q10">Q10:</h3>
<p><strong>How does Django handle performance optimization, and what are some best practices for optimizing the performance of a Django application?</strong></p>
<p>Django includes a number of features that can help developers optimize the performance of their applications, such as caching, database optimization, and load balancing. Developers can also use Django's built-in profiling tools to identify performance bottlenecks and optimize their code accordingly.</p>
<p>Some best practices for optimizing the performance of a Django application include:</p>
<ul>
<li><p>Using caching to reduce the number of database queries and expensive operations</p>
</li>
<li><p>Optimizing database queries by using indexes and avoiding unnecessary queries</p>
</li>
<li><p>Using a load balancer to distribute the load across multiple servers</p>
</li>
<li><p>Using Django's built-in profiling tools to identify and fix performance bottlenecks</p>
</li>
<li><p>Using asynchronous tasks to offload long-running tasks from the main application thread</p>
</li>
<li><p>Minimizing the number of third-party libraries and dependencies to reduce the overall complexity of the application</p>
</li>
<li><p>Monitoring application performance and using tools like New Relic or AppDynamics to identify and fix performance issues</p>
</li>
</ul>
<p>It's important to note that performance optimization is an ongoing process and requires ongoing monitoring and tuning to ensure that the application is performing at its best.</p>
<p><strong><em>Any thoughts? Write it down in the comments.</em></strong></p>
<blockquote>
<p>For more such crispy blogs daily, follow Dev.Junction, subscribe to our newsletter and get notified.</p>
</blockquote>
<h2 id="heading-social-links"><strong>Social Links</strong></h2>
<ul>
<li><p><a target="_blank" href="https://www.linkedin.com/in/mnamegaurav/"><strong>LinkedIn</strong></a><strong>:</strong> <a target="_blank" href="http://linkedin.com/in/mnamegaurav"><strong>linkedin.com/in/mnamegaurav</strong></a></p>
</li>
<li><p><a target="_blank" href="https://www.youtube.com/devjunction"><strong>YouTube</strong></a><strong>:</strong> <a target="_blank" href="http://youtube.com/devjunction"><strong>youtube.com/devjunction</strong></a></p>
</li>
<li><p><a target="_blank" href="https://gaurav.devjunction.in/"><strong>Website</strong></a><strong>:</strong> <a target="_blank" href="http://gaurav.devjunction.in"><strong>gaurav.devjunction.in</strong></a></p>
</li>
<li><p><a target="_blank" href="https://github.com/mnamegaurav"><strong>GitHub</strong></a><strong>:</strong> <a target="_blank" href="http://github.com/mnamegaurav"><strong>github.com/mnamegaurav</strong></a></p>
</li>
<li><p><a target="_blank" href="https://www.instagram.com/mnamegaurav/"><strong>Instagram</strong></a><strong>:</strong> <a target="_blank" href="http://instagram.com/mnamegaurav"><strong>instagram.com/mnamegaurav</strong></a></p>
</li>
<li><p><a target="_blank" href="https://twitter.com/mnamegaurav"><strong>Twitter</strong></a><strong>:</strong> <a target="_blank" href="http://twitter.com/mnamegaurav"><strong>twitter.com/mnamegaurav</strong></a></p>
</li>
</ul>
]]></content:encoded></item><item><title><![CDATA[Introduction to Django Signals: A Simple Guide]]></title><description><![CDATA[Introduction:
Django signals are a powerful tool for sending automatic notifications, updating caches, and performing other tasks in a Django application. They allow you to create "hooks" that trigger certain actions when certain events occur in your...]]></description><link>https://blog.devjunction.in/introduction-to-django-signals-a-simple-guide</link><guid isPermaLink="true">https://blog.devjunction.in/introduction-to-django-signals-a-simple-guide</guid><category><![CDATA[Web Development]]></category><category><![CDATA[webdev]]></category><category><![CDATA[Django]]></category><category><![CDATA[Python]]></category><category><![CDATA[Python 3]]></category><dc:creator><![CDATA[Gaurav Sharma]]></dc:creator><pubDate>Wed, 28 Dec 2022 14:15:27 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1672236048714/e85b0f68-7b3d-4fe0-89de-14e3a241de35.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<h3 id="heading-introduction">Introduction:</h3>
<p>Django signals are a powerful tool for sending automatic notifications, updating caches, and performing other tasks in a Django application. They allow you to create "hooks" that trigger certain actions when certain events occur in your application, such as when a new object is created or deleted. They allow you to decouple the sender of an action from the receiver, making it easier to reuse and maintain your code.</p>
<p>In this article, we'll explore what Django signals are, how they work, and how you can use them in your own Django projects. We'll also cover some best practices for working with signals, and look at some common use cases for signals in a Django application.</p>
<h3 id="heading-what-are-django-signals">What are Django signals?</h3>
<p>Django signals are a way to allow certain parts of your Django application to get notified when certain actions occur elsewhere in the application. For example, you might want to send an email to a user when they create a new account or update the search index when a new blog post is published.</p>
<h3 id="heading-here-are-the-basic-steps-for-using-django-signals">Here are the basic steps for using Django signals:</h3>
<ol>
<li><p>Define a signal: To use Django signals, you first need to define a signal. This involves creating a signal class and specifying the sender and the event that will trigger the signal.</p>
</li>
<li><p>Connect the signal to a receiver: Next, you need to connect the signal to a receiver function. This function will be called whenever the signal is triggered.</p>
</li>
<li><p>Send the signal: Finally, you need to send the signal by calling the <code>send()</code> method of the signal class. This will trigger the signal and execute the receiver function.</p>
</li>
</ol>
<h3 id="heading-heres-an-example-of-a-django-signal-that-sends-an-email-whenever-a-new-user-is-created">Here's an example of a Django signal that sends an email whenever a new user is created:</h3>
<pre><code class="lang-python"><span class="hljs-keyword">from</span> django.contrib.auth.models <span class="hljs-keyword">import</span> User
<span class="hljs-keyword">from</span> django.core.mail <span class="hljs-keyword">import</span> send_mail
<span class="hljs-keyword">from</span> django.db.models.signals <span class="hljs-keyword">import</span> post_save
<span class="hljs-keyword">from</span> django.dispatch <span class="hljs-keyword">import</span> receiver

<span class="hljs-meta">@receiver(post_save, sender=User)</span>
<span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">send_welcome_email</span>(<span class="hljs-params">sender, instance, created, **kwargs</span>):</span>
  <span class="hljs-keyword">if</span> created:
    send_mail(
      <span class="hljs-string">'Welcome to our site!'</span>,
      <span class="hljs-string">'Thank you for joining us. We hope you enjoy your stay.'</span>,
      <span class="hljs-string">'info@example.com'</span>,
      [instance.email],
      fail_silently=<span class="hljs-literal">False</span>,
    )
</code></pre>
<p>In this example, the <code>post_save</code> signal is defined as the sender, and the <code>User</code> model is specified as the event that will trigger the signal. The <code>send_welcome_email</code> function is the receiver function that will be called whenever a new user is created. The <code>send_mail</code> function is called to send the welcome email to the new user.</p>
<p>Another common use case for Django signals is to update caches or search indexes. For example, you might want to update a search index whenever a new blog post is published, or invalidate a cache whenever a user profile is updated.</p>
<p>To update a cache or search index using Django signals, you can define a signal and a receiver function that performs the update. For example:</p>
<pre><code class="lang-python"><span class="hljs-keyword">from</span> django.db.models.signals <span class="hljs-keyword">import</span> post_save
<span class="hljs-keyword">from</span> django.dispatch <span class="hljs-keyword">import</span> receiver
<span class="hljs-keyword">from</span> myapp.utils <span class="hljs-keyword">import</span> update_search_index

<span class="hljs-meta">@receiver(post_save, sender=MyModel)</span>
<span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">update_index</span>(<span class="hljs-params">sender, instance, **kwargs</span>):</span>
    update_search_index(instance)
</code></pre>
<p>In this example, we're using a custom function called <code>update_search_index</code> to update a search index whenever a <code>MyModel</code> object is saved. You can customize this function to suit your needs and use it to update any type of cache or index.</p>
<h3 id="heading-best-practices-for-working-with-django-signals">Best practices for working with Django signals</h3>
<p>As with any tool, it's important to use Django signals responsibly and follow best practices to avoid potential issues. Here are a few tips for working with Django signals:</p>
<ul>
<li><p>Use signals for tasks that are not critical to the application's core functionality. If a task is critical to the application's operation, it's generally better to handle it directly in the code rather than relying on a signal.</p>
</li>
<li><p>Keep receiver functions simple and focused. Avoid performing complex tasks or making multiple database queries in a receiver function, as this can impact the performance of the application.</p>
</li>
<li><p>Use the <code>dispatch_uid</code> argument to prevent multiple copies of a signal from being registered. This can be especially important if you're using Django signals in a reusable app that may be included in multiple projects.</p>
</li>
</ul>
<h3 id="heading-conclusion">Conclusion:</h3>
<p>Django signals are a powerful tool for sending automatic notifications, updating caches, and performing other tasks in a Django application. They allow you to create "hooks" that trigger certain actions when certain events occur in your application, such as when a new object is created or deleted. In this article, we've explored what Django signals are, how they work, and how you can use them in your own Django projects. We've also covered some best practices for working with signals, and looked at some common use cases for signals in a Django application.</p>
<p><strong><em>Any thoughts? Write it down in the comments.</em></strong></p>
<blockquote>
<p><strong><em>For more such crispy blogs daily, follow Dev.Junction, subscribe to our newsletter and get notified.</em></strong></p>
</blockquote>
<h2 id="heading-social-links"><strong>Social Links</strong></h2>
<ul>
<li><p><a target="_blank" href="https://www.linkedin.com/in/mnamegaurav/"><strong>LinkedIn</strong></a><strong>:</strong> <a target="_blank" href="http://linkedin.com/in/mnamegaurav"><strong>linkedin.com/in/mnamegaurav</strong></a></p>
</li>
<li><p><a target="_blank" href="https://www.youtube.com/devjunction"><strong>YouTube</strong></a><strong>:</strong> <a target="_blank" href="http://youtube.com/devjunction"><strong>youtube.com/devjunction</strong></a></p>
</li>
<li><p><a target="_blank" href="https://gaurav.devjunction.in/"><strong>Website</strong></a><strong>:</strong> <a target="_blank" href="http://gaurav.devjunction.in"><strong>gaurav.devjunction.in</strong></a></p>
</li>
<li><p><a target="_blank" href="https://github.com/mnamegaurav"><strong>GitHub</strong></a><strong>:</strong> <a target="_blank" href="http://github.com/mnamegaurav"><strong>github.com/mnamegaurav</strong></a></p>
</li>
<li><p><a target="_blank" href="https://www.instagram.com/mnamegaurav/"><strong>Instagram</strong></a><strong>:</strong> <a target="_blank" href="http://instagram.com/mnamegaurav"><strong>instagram.com/mnamegaurav</strong></a></p>
</li>
<li><p><a target="_blank" href="https://twitter.com/mnamegaurav"><strong>Twitter</strong></a><strong>:</strong> <a target="_blank" href="http://twitter.com/mnamegaurav"><strong>twitter.com/mnamegaurav</strong></a></p>
</li>
</ul>
]]></content:encoded></item><item><title><![CDATA[How to import modules from string in Python?]]></title><description><![CDATA[In Python, you can use the import statement to import a module or package into your code. However, sometimes you may want to dynamically import a module or package from a string, rather than hard coding the module or package name. In this article, we...]]></description><link>https://blog.devjunction.in/how-to-import-modules-from-string-in-python</link><guid isPermaLink="true">https://blog.devjunction.in/how-to-import-modules-from-string-in-python</guid><category><![CDATA[Web Development]]></category><category><![CDATA[webdev]]></category><category><![CDATA[Python]]></category><category><![CDATA[Python 3]]></category><category><![CDATA[python beginner]]></category><dc:creator><![CDATA[Gaurav Sharma]]></dc:creator><pubDate>Tue, 27 Dec 2022 12:42:21 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1672231153278/252d33a7-8c43-4339-9fc8-b4e4c193e251.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>In Python, you can use the <code>import</code> statement to import a module or package into your code. However, sometimes you may want to dynamically import a module or package from a string, rather than hard coding the module or package name. In this article, we'll explore how to import modules from string in Python using the <code>importlib</code> module.</p>
<p>The <code>importlib</code> module provides a number of functions for interacting with the import system, including the <code>import_module</code> function, which can be used to import a module from a string. To use the <code>import_module</code> function, you need to pass it the name of the module as a string, and it will return the module object.</p>
<p>For example, to import the <code>math</code> module from a string, you can use the following code:</p>
<pre><code class="lang-python"><span class="hljs-keyword">import</span> importlib

module_name = <span class="hljs-string">'math'</span>
module = importlib.import_module(module_name)
</code></pre>
<p>Once you have the module object, you can use it like any other module, accessing its attributes and functions using the dot notation. For example, to use the <code>pi</code> constant from the <code>math</code> module, you can use the following code:</p>
<pre><code class="lang-python"><span class="hljs-keyword">import</span> importlib

module_name = <span class="hljs-string">'math'</span>
module = importlib.import_module(module_name)

print(module.pi)  <span class="hljs-comment"># 3.141592653589793</span>
</code></pre>
<p>You can also use the <code>import_module</code> function to import submodules or subpackages from a string. To do this, you simply need to include the submodule or subpackage name in the string, separated by a dot. For example, to import the <code>urllib.parse</code> module from a string, you can use the following code:</p>
<pre><code class="lang-python"><span class="hljs-keyword">import</span> importlib

module_name = <span class="hljs-string">'urllib.parse'</span>
module = importlib.import_module(module_name)
</code></pre>
<p>In addition to the <code>import_module</code> function, the <code>importlib</code> module also provides the <code>import_from_string</code> function, which allows you to import a module or object from a string containing the fully qualified name of the module or object. For example, to import the <code>Decimal</code> class from the <code>decimal</code> module from a string, you can use the following code:</p>
<pre><code class="lang-python"><span class="hljs-keyword">import</span> importlib

module_name = <span class="hljs-string">'decimal.Decimal'</span>
module = importlib.import_from_string(module_name)

decimal = module(<span class="hljs-string">'3.14'</span>)
print(decimal)  <span class="hljs-comment"># 3.14</span>
</code></pre>
<p>In conclusion, the <code>importlib</code> module provides a number of functions for importing modules and objects from string in Python. By using these functions, you can dynamically import modules or objects</p>
<p><strong><em>Any thoughts? Write it down in the comments.</em></strong></p>
<blockquote>
<p><strong><em>For more such crispy blogs daily, follow Dev.Junction, subscribe to our newsletter and get notified.</em></strong></p>
</blockquote>
<h2 id="heading-social-links"><strong>Social Links</strong></h2>
<ul>
<li><p><a target="_blank" href="https://www.linkedin.com/in/mnamegaurav/"><strong>LinkedIn</strong></a><strong>:</strong> <a target="_blank" href="http://linkedin.com/in/mnamegaurav"><strong>linkedin.com/in/mnamegaurav</strong></a></p>
</li>
<li><p><a target="_blank" href="https://www.youtube.com/devjunction"><strong>YouTube</strong></a><strong>:</strong> <a target="_blank" href="http://youtube.com/devjunction"><strong>youtube.com/devjunction</strong></a></p>
</li>
<li><p><a target="_blank" href="https://gaurav.devjunction.in/"><strong>Website</strong></a><strong>:</strong> <a target="_blank" href="http://gaurav.devjunction.in"><strong>gaurav.devjunction.in</strong></a></p>
</li>
<li><p><a target="_blank" href="https://github.com/mnamegaurav"><strong>GitHub</strong></a><strong>:</strong> <a target="_blank" href="http://github.com/mnamegaurav"><strong>github.com/mnamegaurav</strong></a></p>
</li>
<li><p><a target="_blank" href="https://www.instagram.com/mnamegaurav/"><strong>Instagram</strong></a><strong>:</strong> <a target="_blank" href="http://instagram.com/mnamegaurav"><strong>instagram.com/mnamegaurav</strong></a></p>
</li>
<li><p><a target="_blank" href="https://twitter.com/mnamegaurav"><strong>Twitter</strong></a><strong>:</strong> <a target="_blank" href="http://twitter.com/mnamegaurav"><strong>twitter.com/mnamegaurav</strong></a></p>
</li>
</ul>
]]></content:encoded></item><item><title><![CDATA[What are fixtures and how to use it in Django?]]></title><description><![CDATA[Introduction
In Django, fixtures are used to populate the database with initial data. This can be helpful for testing purposes or for setting up a new project with a specific set of data. In this article, we'll explore how to load or dump fixtures in...]]></description><link>https://blog.devjunction.in/what-are-fixtures-and-how-to-use-it-in-django</link><guid isPermaLink="true">https://blog.devjunction.in/what-are-fixtures-and-how-to-use-it-in-django</guid><category><![CDATA[Web Development]]></category><category><![CDATA[webdev]]></category><category><![CDATA[Django]]></category><category><![CDATA[Python]]></category><category><![CDATA[Python 3]]></category><dc:creator><![CDATA[Gaurav Sharma]]></dc:creator><pubDate>Mon, 26 Dec 2022 17:34:17 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1672075943715/2b35018e-d953-4ef5-8101-918ee83b37e0.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<h1 id="heading-introduction">Introduction</h1>
<p>In Django, fixtures are used to populate the database with initial data. This can be helpful for testing purposes or for setting up a new project with a specific set of data. In this article, we'll explore how to load or dump fixtures in Django using the <code>loaddata</code> and <code>dumpdata</code> management commands.</p>
<h1 id="heading-loading-data">Loading data:</h1>
<p>To load fixtures in Django, you can use the <code>loaddata</code> management command. This command takes the name of the fixture file as an argument and loads the data from the fixture into the database. For example, loading the <code>initial_data.json</code> fixture file, you can run the following command:</p>
<pre><code class="lang-bash">python manage.py loaddata initial_data.json
</code></pre>
<p>The <code>loaddata</code> command can also take multiple fixture files as arguments, separated by spaces. For example, to load both the <code>initial_data.json</code> and <code>additional_data.json</code> fixture files, you can run the following command:</p>
<pre><code class="lang-bash">python manage.py loaddata initial_data.json additional_data.json
</code></pre>
<h1 id="heading-dumping-data">Dumping Data:</h1>
<p>To dump fixtures in Django, you can use the <code>dumpdata</code> management command. This command takes the name of the Django app as an argument and creates a fixture file with the data from the app's models. For example, to dump the data from the <code>polls</code> app, you can run the following command:</p>
<pre><code class="lang-bash">python manage.py dumpdata polls &gt; polls_data.json
</code></pre>
<p>The <code>dumpdata</code> command can also take multiple app names as arguments, separated by spaces. For example, to dump the data from both the <code>polls</code> and <code>users</code> apps, you can run the following command:</p>
<pre><code class="lang-bash">python manage.py dumpdata polls users &gt; app_data.json
</code></pre>
<p>In addition to taking app names as arguments, the <code>dumpdata</code> command also supports several options for customizing the data that is dumped. For example, you can use the <code>--indent</code> option to specify the number of spaces to use for indentation in the fixture file, or the <code>--exclude</code> option to exclude specific models or fields from the fixture.</p>
<h1 id="heading-conclusion">Conclusion:</h1>
<p>In conclusion, the <code>loaddata</code> and <code>dumpdata</code> management commands are useful tools for loading or dumping fixtures in Django. By using these commands, you can easily populate the database with initial data or create a fixture file with the data from your Django models.</p>
<p><strong><em>Any thoughts? Write it down in the comments.</em></strong></p>
<blockquote>
<p><strong><em>For more such crispy blogs daily, follow Dev.Junction, subscribe to our newsletter and get notified.</em></strong></p>
</blockquote>
<h2 id="heading-social-links"><strong>Social Links</strong></h2>
<ul>
<li><p><a target="_blank" href="https://www.linkedin.com/in/mnamegaurav/"><strong>LinkedIn</strong></a><strong>:</strong> <a target="_blank" href="http://linkedin.com/in/mnamegaurav"><strong>linkedin.com/in/mnamegaurav</strong></a></p>
</li>
<li><p><a target="_blank" href="https://www.youtube.com/devjunction"><strong>YouTube</strong></a><strong>:</strong> <a target="_blank" href="http://youtube.com/devjunction"><strong>youtube.com/devjunction</strong></a></p>
</li>
<li><p><a target="_blank" href="https://gaurav.devjunction.in/"><strong>Website</strong></a><strong>:</strong> <a target="_blank" href="http://gaurav.devjunction.in"><strong>gaurav.devjunction.in</strong></a></p>
</li>
<li><p><a target="_blank" href="https://github.com/mnamegaurav"><strong>GitHub</strong></a><strong>:</strong> <a target="_blank" href="http://github.com/mnamegaurav"><strong>github.com/mnamegaurav</strong></a></p>
</li>
<li><p><a target="_blank" href="https://www.instagram.com/mnamegaurav/"><strong>Instagram</strong></a><strong>:</strong> <a target="_blank" href="http://instagram.com/mnamegaurav"><strong>instagram.com/mnamegaurav</strong></a></p>
</li>
<li><p><a target="_blank" href="https://twitter.com/mnamegaurav"><strong>Twitter</strong></a><strong>:</strong> <a target="_blank" href="http://twitter.com/mnamegaurav"><strong>twitter.com/mnamegaurav</strong></a></p>
</li>
</ul>
]]></content:encoded></item><item><title><![CDATA[Django Admin Customization: Adding Custom Views in Django admin]]></title><description><![CDATA[Hey everyone!
If you're a Django developer, you know that the Django Admin interface is a convenient tool for managing your project's data. But did you know that you can also add custom views to Django Admin to expand its functionality?
Custom views ...]]></description><link>https://blog.devjunction.in/django-admin-customization-adding-custom-views-in-django-admin</link><guid isPermaLink="true">https://blog.devjunction.in/django-admin-customization-adding-custom-views-in-django-admin</guid><category><![CDATA[Web Development]]></category><category><![CDATA[webdev]]></category><category><![CDATA[Django]]></category><category><![CDATA[Python]]></category><category><![CDATA[Python 3]]></category><dc:creator><![CDATA[Gaurav Sharma]]></dc:creator><pubDate>Sun, 25 Dec 2022 07:32:21 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1671953404970/4264fa20-16ec-4f9e-b52f-798154251685.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Hey everyone!</p>
<p>If you're a Django developer, you know that the Django Admin interface is a convenient tool for managing your project's data. But did you know that you can also add custom views to Django Admin to expand its functionality?</p>
<p>Custom views in Django Admin allow you to create custom pages or actions that are accessible from the admin interface. This can be useful for tasks that don't fit neatly into the standard CRUD (create, read, update, delete) operations, or for adding custom functionality to the admin interface.</p>
<p>To create a custom view in Django Admin, you'll need to define a function and decorate it with <code>@</code><a target="_blank" href="http://admin.site"><code>admin.site</code></a><code>.admin_view</code> or <code>@</code><a target="_blank" href="http://admin.site"><code>admin.site</code></a><code>.login_required</code>.</p>
<p>Here's an example of how to do this:</p>
<pre><code class="lang-python"><span class="hljs-comment"># myapp/admin.py</span>

<span class="hljs-keyword">from</span> django.contrib <span class="hljs-keyword">import</span> admin

<span class="hljs-meta">@admin.site.login_required</span>
<span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">my_custom_view</span>(<span class="hljs-params">request</span>):</span>
    <span class="hljs-comment"># perform some custom action</span>
    <span class="hljs-comment"># ...</span>
    <span class="hljs-keyword">return</span> render(request, <span class="hljs-string">'my_custom_template.html'</span>)

<span class="hljs-comment"># register the custom view</span>
admin.site.register_view(<span class="hljs-string">'my-custom-view/'</span>, view=my_custom_view, name=<span class="hljs-string">'My Custom View'</span>)
</code></pre>
<p>Now, you can access the custom view by visiting <code>/admin/my-custom-view/</code> in your browser.</p>
<p>Custom views in Django Admin can be a great way to add extra functionality or tailor the admin interface to your specific needs. Don't be afraid to experiment and see what works best for your project.</p>
<p>Happy coding!</p>
<p><strong><em>Any thoughts? Write it down in the comments.</em></strong></p>
<blockquote>
<p><strong><em>For more such crispy blogs daily, follow Dev.Junction, subscribe to our newsletter and get notified.</em></strong></p>
</blockquote>
<h2 id="heading-social-links"><strong>Social Links</strong></h2>
<ul>
<li><p><a target="_blank" href="https://www.linkedin.com/in/mnamegaurav/"><strong>LinkedIn</strong></a><strong>:</strong> <a target="_blank" href="http://linkedin.com/in/mnamegaurav"><strong>linkedin.com/in/mnamegaurav</strong></a></p>
</li>
<li><p><a target="_blank" href="https://www.youtube.com/devjunction"><strong>YouTube</strong></a><strong>:</strong> <a target="_blank" href="http://youtube.com/devjunction"><strong>youtube.com/devjunction</strong></a></p>
</li>
<li><p><a target="_blank" href="https://gaurav.devjunction.in/"><strong>Website</strong></a><strong>:</strong> <a target="_blank" href="http://gaurav.devjunction.in"><strong>gaurav.devjunction.in</strong></a></p>
</li>
<li><p><a target="_blank" href="https://github.com/mnamegaurav"><strong>GitHub</strong></a><strong>:</strong> <a target="_blank" href="http://github.com/mnamegaurav"><strong>github.com/mnamegaurav</strong></a></p>
</li>
<li><p><a target="_blank" href="https://www.instagram.com/mnamegaurav/"><strong>Instagram</strong></a><strong>:</strong> <a target="_blank" href="http://instagram.com/mnamegaurav"><strong>instagram.com/mnamegaurav</strong></a></p>
</li>
<li><p><a target="_blank" href="https://twitter.com/mnamegaurav"><strong>Twitter</strong></a><strong>:</strong> <a target="_blank" href="http://twitter.com/mnamegaurav"><strong>twitter.com/mnamegaurav</strong></a></p>
</li>
</ul>
]]></content:encoded></item><item><title><![CDATA[How to create Custom Django Admin List Filters?]]></title><description><![CDATA[Hey everyone!
If you're using Django Admin to manage your project's data, you know that the ability to filter and organize your models is crucial. That's where list filters come in.

List filters are a built-in feature of Django Admin that allows you...]]></description><link>https://blog.devjunction.in/how-to-create-custom-django-admin-list-filters</link><guid isPermaLink="true">https://blog.devjunction.in/how-to-create-custom-django-admin-list-filters</guid><category><![CDATA[Web Development]]></category><category><![CDATA[webdev]]></category><category><![CDATA[Python]]></category><category><![CDATA[Django]]></category><category><![CDATA[Python 3]]></category><dc:creator><![CDATA[Gaurav Sharma]]></dc:creator><pubDate>Sat, 24 Dec 2022 07:27:37 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1671953203502/c0d96f1a-b4de-4c36-840b-f00954219118.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Hey everyone!</p>
<p>If you're using Django Admin to manage your project's data, you know that the ability to filter and organize your models is crucial. That's where list filters come in.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1672208658577/00485f0f-f335-456c-a8f7-f4e626a67e8b.png" alt class="image--center mx-auto" /></p>
<p>List filters are a built-in feature of Django Admin that allows you to narrow down the list of model instances based on certain criteria. By default, Django Admin provides filters for each model field, but you can also define custom filters to meet your specific needs.</p>
<p>To create a custom list filter, you'll need to define a subclass of <code>SimpleListFilter</code> and override the <code>lookups</code> and <code>queryset</code> methods.</p>
<p>Here's an example of how to do this:</p>
<pre><code class="lang-python"><span class="hljs-comment"># myapp/admin.py</span>

<span class="hljs-keyword">from</span> django.contrib <span class="hljs-keyword">import</span> admin
<span class="hljs-keyword">from</span> django.utils.translation <span class="hljs-keyword">import</span> gettext_lazy <span class="hljs-keyword">as</span> _

<span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">MyCustomFilter</span>(<span class="hljs-params">admin.SimpleListFilter</span>):</span>
    title = _(<span class="hljs-string">'custom filter'</span>)
    parameter_name = <span class="hljs-string">'custom_filter'</span>

    <span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">lookups</span>(<span class="hljs-params">self, request, model_admin</span>):</span>
        <span class="hljs-comment"># define the filter options</span>
        <span class="hljs-keyword">return</span> (
            (<span class="hljs-string">'option1'</span>, _(<span class="hljs-string">'Option 1'</span>)),
            (<span class="hljs-string">'option2'</span>, _(<span class="hljs-string">'Option 2'</span>)),
        )

    <span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">queryset</span>(<span class="hljs-params">self, request, queryset</span>):</span>
        <span class="hljs-comment"># apply the filter to the queryset</span>
        <span class="hljs-keyword">if</span> self.value() == <span class="hljs-string">'option1'</span>:
            <span class="hljs-keyword">return</span> queryset.filter(field1=<span class="hljs-string">'value1'</span>)
        <span class="hljs-keyword">if</span> self.value() == <span class="hljs-string">'option2'</span>:
            <span class="hljs-keyword">return</span> queryset.filter(field2=<span class="hljs-string">'value2'</span>)

<span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">MyModelAdmin</span>(<span class="hljs-params">admin.ModelAdmin</span>):</span>
    ...
    list_filter = [MyCustomFilter]

<span class="hljs-comment"># register the model with the custom filter</span>
admin.site.register(MyModel, MyModelAdmin)
</code></pre>
<p>And that's it! You now have a custom list filter available in Django Admin.</p>
<p>Custom list filters are a great way to make it easier for users to find the data they need, so don't be afraid to experiment and see what works best for your project.</p>
<p>Happy coding!</p>
<p><strong><em>Any thoughts? Write it down in the comments.</em></strong></p>
<blockquote>
<p><strong><em>For more such crispy blogs daily, follow Dev.Junction, subscribe to our newsletter and get notified.</em></strong></p>
</blockquote>
<h2 id="heading-social-links"><strong>Social Links</strong></h2>
<ul>
<li><p><a target="_blank" href="https://www.linkedin.com/in/mnamegaurav/"><strong>LinkedIn</strong></a><strong>:</strong> <a target="_blank" href="http://linkedin.com/in/mnamegaurav"><strong>linkedin.com/in/mnamegaurav</strong></a></p>
</li>
<li><p><a target="_blank" href="https://www.youtube.com/devjunction"><strong>YouTube</strong></a><strong>:</strong> <a target="_blank" href="http://youtube.com/devjunction"><strong>youtube.com/devjunction</strong></a></p>
</li>
<li><p><a target="_blank" href="https://gaurav.devjunction.in/"><strong>Website</strong></a><strong>:</strong> <a target="_blank" href="http://gaurav.devjunction.in"><strong>gaurav.devjunction.in</strong></a></p>
</li>
<li><p><a target="_blank" href="https://github.com/mnamegaurav"><strong>GitHub</strong></a><strong>:</strong> <a target="_blank" href="http://github.com/mnamegaurav"><strong>github.com/mnamegaurav</strong></a></p>
</li>
<li><p><a target="_blank" href="https://www.instagram.com/mnamegaurav/"><strong>Instagram</strong></a><strong>:</strong> <a target="_blank" href="http://instagram.com/mnamegaurav"><strong>instagram.com/mnamegaurav</strong></a></p>
</li>
<li><p><a target="_blank" href="https://twitter.com/mnamegaurav"><strong>Twitter</strong></a><strong>:</strong> <a target="_blank" href="http://twitter.com/mnamegaurav"><strong>twitter.com/mnamegaurav</strong></a></p>
</li>
</ul>
]]></content:encoded></item><item><title><![CDATA[Boost Your Django Project with Custom Model Forms]]></title><description><![CDATA[Hey everyone!
If you're working with Django, you know that the Django Admin interface is a powerful tool for managing your project's data. But did you know that you can also customize the forms used in the admin interface to fit your specific needs?
...]]></description><link>https://blog.devjunction.in/boost-your-django-project-with-custom-model-forms</link><guid isPermaLink="true">https://blog.devjunction.in/boost-your-django-project-with-custom-model-forms</guid><category><![CDATA[Web Development]]></category><category><![CDATA[webdev]]></category><category><![CDATA[Python]]></category><category><![CDATA[Django]]></category><category><![CDATA[Python 3]]></category><dc:creator><![CDATA[Gaurav Sharma]]></dc:creator><pubDate>Fri, 23 Dec 2022 07:21:20 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1671952758991/f4d09bd1-cbaf-499e-9d35-333aa553725c.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Hey everyone!</p>
<p>If you're working with Django, you know that the Django Admin interface is a powerful tool for managing your project's data. But did you know that you can also customize the forms used in the admin interface to fit your specific needs?</p>
<p>By default, Django Admin uses a standard form for creating and updating model instances. But you can override this form by defining a <code>ModelAdmin.form</code> attribute in your <code>ModelAdmin</code> class.</p>
<p>Here's an example of how to do this:</p>
<pre><code class="lang-python"><span class="hljs-comment"># myapp/admin.py</span>

<span class="hljs-keyword">from</span> django.contrib <span class="hljs-keyword">import</span> admin
<span class="hljs-keyword">from</span> django <span class="hljs-keyword">import</span> forms

<span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">MyModelForm</span>(<span class="hljs-params">forms.ModelForm</span>):</span>
    <span class="hljs-comment"># add custom fields or widgets to the form</span>
    custom_field = forms.CharField(max_length=<span class="hljs-number">100</span>)

    <span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">Meta</span>:</span>
        model = MyModel
        fields = [<span class="hljs-string">'field1'</span>, <span class="hljs-string">'field2'</span>, <span class="hljs-string">'custom_field'</span>]

<span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">MyModelAdmin</span>(<span class="hljs-params">admin.ModelAdmin</span>):</span>
    ...
    form = MyModelForm

<span class="hljs-comment"># register the model with the custom form</span>
admin.site.register(MyModel, MyModelAdmin)
</code></pre>
<p>Now, when you create or update a <code>MyModel</code> instance in Django Admin, the form will include the <code>custom_field</code> that you defined.</p>
<p>Customizing the model form can be a great way to add extra functionality or tailor the form to your specific needs. Don't be afraid to experiment and see what works best for your project.</p>
<p>Happy coding!</p>
<p><strong><em>Any thoughts? Write it down in the comments.</em></strong></p>
<blockquote>
<p><strong><em>For more such crispy blogs daily, follow Dev.Junction, subscribe to our newsletter and get notified.</em></strong></p>
</blockquote>
<h2 id="heading-social-links"><strong>Social Links</strong></h2>
<ul>
<li><p><a target="_blank" href="https://www.linkedin.com/in/mnamegaurav/"><strong>LinkedIn</strong></a><strong>:</strong> <a target="_blank" href="http://linkedin.com/in/mnamegaurav"><strong>linkedin.com/in/mnamegaurav</strong></a></p>
</li>
<li><p><a target="_blank" href="https://www.youtube.com/devjunction"><strong>YouTube</strong></a><strong>:</strong> <a target="_blank" href="http://youtube.com/devjunction"><strong>youtube.com/devjunction</strong></a></p>
</li>
<li><p><a target="_blank" href="https://gaurav.devjunction.in/"><strong>Website</strong></a><strong>:</strong> <a target="_blank" href="http://gaurav.devjunction.in"><strong>gaurav.devjunction.in</strong></a></p>
</li>
<li><p><a target="_blank" href="https://github.com/mnamegaurav"><strong>GitHub</strong></a><strong>:</strong> <a target="_blank" href="http://github.com/mnamegaurav"><strong>github.com/mnamegaurav</strong></a></p>
</li>
<li><p><a target="_blank" href="https://www.instagram.com/mnamegaurav/"><strong>Instagram</strong></a><strong>:</strong> <a target="_blank" href="http://instagram.com/mnamegaurav"><strong>instagram.com/mnamegaurav</strong></a></p>
</li>
<li><p><a target="_blank" href="https://twitter.com/mnamegaurav"><strong>Twitter</strong></a><strong>:</strong> <a target="_blank" href="http://twitter.com/mnamegaurav"><strong>twitter.com/mnamegaurav</strong></a></p>
</li>
</ul>
]]></content:encoded></item><item><title><![CDATA[Django Admin 101: How to Add Custom Actions to the Model List View?]]></title><description><![CDATA[Hey everyone!
If you're a Django developer, you're probably familiar with the Django Admin interface. It's a built-in tool that allows you to manage your Django project's data through a web interface, making it easy to perform CRUD (create, read, upd...]]></description><link>https://blog.devjunction.in/django-admin-101-how-to-add-custom-actions-to-the-model-list-view</link><guid isPermaLink="true">https://blog.devjunction.in/django-admin-101-how-to-add-custom-actions-to-the-model-list-view</guid><category><![CDATA[Django]]></category><category><![CDATA[Python]]></category><category><![CDATA[Python 3]]></category><category><![CDATA[python beginner]]></category><category><![CDATA[Web Development]]></category><dc:creator><![CDATA[Gaurav Sharma]]></dc:creator><pubDate>Thu, 22 Dec 2022 07:15:29 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1671952380259/db5fdd42-ff12-4315-9a7e-62c01544a2df.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Hey everyone!</p>
<p>If you're a Django developer, you're probably familiar with the Django Admin interface. It's a built-in tool that allows you to manage your Django project's data through a web interface, making it easy to perform CRUD (create, read, update, delete) operations on your models.</p>
<p>One thing I love about Django Admin is how customizable it is. You can easily customize the look and feel of the interface, as well as the functionality.</p>
<p>For example, let's say you want to add a custom action to the model list view. You can do this by using the <code>ModelAdmin.actions</code> attribute and defining a function that takes in a <code>request</code> and a <code>queryset</code> of objects.</p>
<p>Here's an example of how to do this:</p>
<pre><code class="lang-python"><span class="hljs-comment"># myapp/admin.py</span>

<span class="hljs-keyword">from</span> django.contrib <span class="hljs-keyword">import</span> admin

<span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">MyModelAdmin</span>(<span class="hljs-params">admin.ModelAdmin</span>):</span>
    actions = [<span class="hljs-string">'custom_action'</span>]

    <span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">custom_action</span>(<span class="hljs-params">self, request, queryset</span>):</span>
        <span class="hljs-comment"># perform some custom action on the selected objects</span>
        <span class="hljs-keyword">for</span> obj <span class="hljs-keyword">in</span> queryset:
            obj.do_something()
        self.message_user(request, <span class="hljs-string">"Custom action performed on {} objects."</span>.format(len(queryset)))

<span class="hljs-comment"># register the model with the custom action</span>
admin.site.register(MyModel, MyModelAdmin)
</code></pre>
<p>And that's it! Now you have a custom action available on the model list view in Django Admin.</p>
<p>There are endless possibilities when it comes to customizing Django Admin, so make sure to check out the documentation for more information.</p>
<p>Happy coding!</p>
<p><strong><em>Any thoughts? Write it down in the comments.</em></strong></p>
<blockquote>
<p><strong><em>For more such crispy blogs daily, follow Dev.Junction, subscribe to our newsletter and get notified.</em></strong></p>
</blockquote>
<h2 id="heading-social-links"><strong>Social Links</strong></h2>
<ul>
<li><p><a target="_blank" href="https://www.linkedin.com/in/mnamegaurav/"><strong>LinkedIn</strong></a><strong>:</strong> <a target="_blank" href="http://linkedin.com/in/mnamegaurav"><strong>linkedin.com/in/mnamegaurav</strong></a></p>
</li>
<li><p><a target="_blank" href="https://www.youtube.com/devjunction"><strong>YouTube</strong></a><strong>:</strong> <a target="_blank" href="http://youtube.com/devjunction"><strong>youtube.com/devjunction</strong></a></p>
</li>
<li><p><a target="_blank" href="https://gaurav.devjunction.in/"><strong>Website</strong></a><strong>:</strong> <a target="_blank" href="http://gaurav.devjunction.in"><strong>gaurav.devjunction.in</strong></a></p>
</li>
<li><p><a target="_blank" href="https://github.com/mnamegaurav"><strong>GitHub</strong></a><strong>:</strong> <a target="_blank" href="http://github.com/mnamegaurav"><strong>github.com/mnamegaurav</strong></a></p>
</li>
<li><p><a target="_blank" href="https://www.instagram.com/mnamegaurav/"><strong>Instagram</strong></a><strong>:</strong> <a target="_blank" href="http://instagram.com/mnamegaurav"><strong>instagram.com/mnamegaurav</strong></a></p>
</li>
<li><p><a target="_blank" href="https://twitter.com/mnamegaurav"><strong>Twitter</strong></a><strong>:</strong> <a target="_blank" href="http://twitter.com/mnamegaurav"><strong>twitter.com/mnamegaurav</strong></a></p>
</li>
</ul>
]]></content:encoded></item><item><title><![CDATA[What is the new Self Type in Python 3.11?]]></title><description><![CDATA[If you have been using Typehints in Python, you are already aware of how we use Types in Python, although keep in mind that the Python runtime does not enforce function and variable type annotations. They can be used by third party tools such as type...]]></description><link>https://blog.devjunction.in/what-is-the-new-self-type-in-python-3-11</link><guid isPermaLink="true">https://blog.devjunction.in/what-is-the-new-self-type-in-python-3-11</guid><category><![CDATA[Python]]></category><category><![CDATA[Python 3]]></category><category><![CDATA[python beginner]]></category><category><![CDATA[Programming Blogs]]></category><category><![CDATA[Programming Tips]]></category><dc:creator><![CDATA[Gaurav Sharma]]></dc:creator><pubDate>Tue, 20 Dec 2022 23:17:19 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1671835143899/31d8b338-5767-4e51-9663-c56b53c984b5.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>If you have been using <code>Typehints</code> in Python, you are already aware of how we use Types in Python, although keep in mind that the Python runtime does not enforce function and variable type annotations. They can be used by third party tools such as type checkers, IDEs, linters, etc.</p>
<p>In the freshly released Python 3.11 (2022-10-24) also known as <a target="_blank" href="https://peps.python.org/pep-0664/">PEP-664</a>, so many features have been introduced such as faster CPython, Support for parsing TOML &amp; <code>Self</code> Type and much more.</p>
<p>Let's focus on <code>Self</code> Type for this blog. <code>Self</code> Type is defined in <a target="_blank" href="https://peps.python.org/pep-0673/"><strong>PEP 673 – Self Type</strong></a><strong>.</strong> But What is the use case of this <code>Self</code> type? Let's understand by an example.</p>
<pre><code class="lang-python"><span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">Shape</span>:</span>
    <span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">set_scale</span>(<span class="hljs-params">self, scale: float</span>):</span>
        self.scale = scale
        <span class="hljs-keyword">return</span> self

Shape().set_scale(<span class="hljs-number">0.5</span>)  <span class="hljs-comment"># =&gt; Return type should be Shape</span>
</code></pre>
<p>As given in the above example, <code>set_scale</code> will return the <code>instance</code> itself, which will allow us to do method chaining. But how do we define the return type of <code>set_scale</code> above?</p>
<p>One way to denote the return type is to specify it as the current class, say, <code>Shape</code>. Using the method makes the type checker infer the type <code>Shape</code>, as expected.</p>
<pre><code class="lang-python"><span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">Shape</span>:</span>
    <span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">set_scale</span>(<span class="hljs-params">self, scale: float</span>) -&gt; Shape:</span>
        self.scale = scale
        <span class="hljs-keyword">return</span> self

Shape().set_scale(<span class="hljs-number">0.5</span>)  <span class="hljs-comment"># =&gt; Return type is Shape</span>
</code></pre>
<p>So we have got the solution, but is it really going to work if we create a subclass of <code>Shape</code> and use the <code>set_scale</code> method in that subclass? The answer is no, let's understand from the below code.</p>
<pre><code class="lang-python"><span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">Circle</span>(<span class="hljs-params">Shape</span>):</span>
    <span class="hljs-comment"># Circle is a Subclass of Shape</span>
    <span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">set_radius</span>(<span class="hljs-params">self, r: float</span>) -&gt; Circle:</span>
        self.radius = r
        <span class="hljs-keyword">return</span> self

Circle().set_scale(<span class="hljs-number">0.5</span>)  <span class="hljs-comment"># Return type is *Shape*, not Circle</span>
Circle().set_scale(<span class="hljs-number">0.5</span>).set_radius(<span class="hljs-number">2.7</span>) <span class="hljs-comment"># =&gt; Error: Shape has no attribute set_radius</span>
</code></pre>
<p>As given in the above example, the IDE will show an error on the last line because <code>Circle().set_scale(0.5)</code> return type is <code>Shape</code> and IDE is not able to parse that we are calling <code>set_scale</code> from <code>Circle</code> not <code>Shape</code>. Hence, the new <code>Self</code> needs to be introduced. Let's understand how it works.</p>
<pre><code class="lang-python"><span class="hljs-keyword">from</span> typing <span class="hljs-keyword">import</span> Self  <span class="hljs-comment"># New Self type</span>

<span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">Shape</span>:</span>
    <span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">set_scale</span>(<span class="hljs-params">self, scale: float</span>) -&gt; Self:</span>
        self.scale = scale
        <span class="hljs-keyword">return</span> self

<span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">Circle</span>(<span class="hljs-params">Shape</span>):</span>
    <span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">set_radius</span>(<span class="hljs-params">self, radius: float</span>) -&gt; Self:</span>
        self.radius = radius
        <span class="hljs-keyword">return</span> self

Shape().set_scale(<span class="hljs-number">0.5</span>) <span class="hljs-comment"># Return type is *Shape*</span>
Circle().set_scale(<span class="hljs-number">0.5</span>)  <span class="hljs-comment"># Return type is *Circle*</span>
Circle().set_scale(<span class="hljs-number">0.5</span>).set_radius(<span class="hljs-number">2.7</span>) <span class="hljs-comment"># Return type is *Circle*</span>
</code></pre>
<p>Above, the return type <code>Self</code> represents the fact that the function returns <code>self</code> (which is an <code>instance</code> of the class) and is easier to understand.</p>
<p>As in the above example, the type checker will correctly infer the type of <code>Circle().set_scale(0.5)</code> to be <code>Circle</code>, as expected.</p>
<p>This is it for today.</p>
<p><strong><em>Any thoughts? Write it down in the comments.</em></strong></p>
<blockquote>
<p><strong><em>For more such crispy blogs daily, follow Dev.Junction, subscribe to our newsletter and get notified.</em></strong></p>
</blockquote>
<h2 id="heading-social-links"><strong>Social Links</strong></h2>
<ul>
<li><p><a target="_blank" href="https://www.linkedin.com/in/mnamegaurav/"><strong>LinkedIn</strong></a><strong>:</strong> <a target="_blank" href="http://linkedin.com/in/mnamegaurav"><strong>linkedin.com/in/mnamegaurav</strong></a></p>
</li>
<li><p><a target="_blank" href="https://www.youtube.com/devjunction"><strong>YouTube</strong></a><strong>:</strong> <a target="_blank" href="http://youtube.com/devjunction"><strong>youtube.com/devjunction</strong></a></p>
</li>
<li><p><a target="_blank" href="https://gaurav.devjunction.in/"><strong>Website</strong></a><strong>:</strong> <a target="_blank" href="http://gaurav.devjunction.in"><strong>gaurav.devjunction.in</strong></a></p>
</li>
<li><p><a target="_blank" href="https://github.com/mnamegaurav"><strong>GitHub</strong></a><strong>:</strong> <a target="_blank" href="http://github.com/mnamegaurav"><strong>github.com/mnamegaurav</strong></a></p>
</li>
<li><p><a target="_blank" href="https://www.instagram.com/mnamegaurav/"><strong>Instagram</strong></a><strong>:</strong> <a target="_blank" href="http://instagram.com/mnamegaurav"><strong>instagram.com/mnamegaurav</strong></a></p>
</li>
<li><p><a target="_blank" href="https://twitter.com/mnamegaurav"><strong>Twitter</strong></a><strong>:</strong> <a target="_blank" href="http://twitter.com/mnamegaurav"><strong>twitter.com/mnamegaurav</strong></a></p>
</li>
</ul>
]]></content:encoded></item><item><title><![CDATA[15 Essential Chrome Extensions for Web Developers]]></title><description><![CDATA[1. daily.dev | The Homepage Developers Deserve:
daily.dev is the fastest-growing online community for developers to stay updated on the best developer news. Get all the content you love in one place collected from +400 sources, and get a feed of the ...]]></description><link>https://blog.devjunction.in/15-essential-chrome-extensions-for-web-developers</link><guid isPermaLink="true">https://blog.devjunction.in/15-essential-chrome-extensions-for-web-developers</guid><category><![CDATA[Web Development]]></category><category><![CDATA[webdev]]></category><category><![CDATA[Programming Blogs]]></category><category><![CDATA[Programming Tips]]></category><category><![CDATA[Open Source]]></category><dc:creator><![CDATA[Gaurav Sharma]]></dc:creator><pubDate>Tue, 20 Dec 2022 00:30:42 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1671119415536/VFH4rrgCz.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<h3 id="heading-1-dailydevhttpdailydev-or-the-homepage-developers-deserve">1. <a target="_blank" href="http://daily.dev"><strong>daily.dev</strong></a> <strong>| The Homepage Developers Deserve:</strong></h3>
<p><a target="_blank" href="http://daily.dev">daily.dev</a> is the fastest-growing online community for developers to stay updated on the best developer news. Get all the content you love in one place collected from +400 sources, and get a feed of the hottest developer news personalized to you.</p>
<h3 id="heading-2-lighthouse">2. Lighthouse</h3>
<p><a target="_blank" href="https://chrome.google.com/webstore/detail/lighthouse/blipmdconlkpinefehnmjammfjpmpbjk">Lighthouse</a> is an open-source, automated tool for improving the performance, quality, and correctness of your web apps.</p>
<p>When auditing a page, Lighthouse runs a barrage of tests against the page and then generates a report on how well the page did. From here, you can use the failing tests as indicators of what you can do to improve your app.</p>
<h3 id="heading-3-react-developer-tools">3. React Developer Tools</h3>
<p><a target="_blank" href="https://chrome.google.com/webstore/detail/react-developer-tools/fmkadmapgofadopljbjfkapdkoienihi?hl=en">React Developer Tools</a> is a Chrome DevTools extension for the open-source React JavaScript library. It allows you to inspect the React component hierarchies in the Chrome Developer Tools.</p>
<h3 id="heading-4-visbug">4. VisBug</h3>
<p><a target="_blank" href="https://chrome.google.com/webstore/detail/visbug/cdockenadnadldjbbgcallicgledbeoc?hl=en">VisBug</a> is an Open source web design debug tool built with JavaScript. Using this, you can Point, click, move, resize, Edit or style any page, in any state, inspect styles, spacing, distance, accessibility and alignment, and Nitpick layouts &amp; content, in the real end environment, at any device size, Leverage adobe/sketch skills, edit text, replace images and much more.</p>
<h3 id="heading-5-amino-live-css-editor">5. Amino: Live CSS Editor</h3>
<p><a target="_blank" href="https://chrome.google.com/webstore/detail/amino/pbcpfbcibpcbfbmddogfhcijfpboeaaf">Amino</a> is a free browser extension that lets you write and apply custom CSS to any website, allowing you to customize colors, fonts, page layout and more. Your custom CSS is stored in the cloud and is loaded every time the page is viewed, allowing you to permanently customize your experience of any site you want. See your custom CSS in action on any desktop browser where Amino is installed.</p>
<h3 id="heading-6-html-to-figma-by-builderiohttpbuilderio">6. HTML to Figma - by <a target="_blank" href="http://Builder.io">Builder.io</a></h3>
<p>Use this <a target="_blank" href="https://chrome.google.com/webstore/detail/html-to-figma-by-builderi/efjcmgblfpkhbjpkpopkgeomfkokpaim">extension</a> to capture your current page and import it as editable Figma layers! You can easily import real live site styles as a starting point for designs and prototypes, quickly turn real site components into design components, easily import components from the storybook and much more.</p>
<h3 id="heading-7-css-peeper">7. CSS Peeper</h3>
<p><a target="_blank" href="https://chrome.google.com/webstore/detail/css-peeper/mbnbehikldjhnfehhnaidhjhoofhpehk?hl=en">CSS Peeper</a> is an extension using which you can extract CSS and build beautiful style guides, you can also inspect styles in a simple, well-organized &amp; beautiful way. CSS Peeper is a CSS viewer tailored for Designers.</p>
<h3 id="heading-8-whatfont">8. WhatFont</h3>
<p><a target="_blank" href="https://chrome.google.com/webstore/detail/whatfont/jabopobgcpjmedljpbcaablpmlmfcogm?hl=en">WhatFont</a> is the easiest way to identify fonts on web pages. With this extension, you could inspect web fonts by just hovering over them. It is that simple and elegant. It also detects the services used for serving web fonts. Supports Typekit and Google Font API.</p>
<h3 id="heading-9-browserstack">9. BrowserStack</h3>
<p>With <a target="_blank" href="https://chrome.google.com/webstore/detail/browserstack/nkihdmlheodkdfojglpcjjmioefjahjb?hl=en">BrowserStack</a>, you can instantly test your webpage on up to 12 of any desktop or mobile browser. Your webpage will be launched in the combination selected. Test this webpage using BrowserStack’s Dev Tools, check page behavior in real user conditions and file bugs directly.</p>
<h3 id="heading-10-html-validator">10. HTML Validator</h3>
<p><a target="_blank" href="https://chrome.google.com/webstore/detail/html-validator/mpbelhhnfhfjnaehkcnnaknldmnocglk">HTML Validator</a> for Chrome is a browser extension that adds HTML validation inside the Developer Tools of Chrome. The number of errors of an HTML page is seen with an icon in the browser status bar. The details are seen in the developer tools.</p>
<h3 id="heading-11-colorzilla">11. Colorzilla</h3>
<p><a target="_blank" href="https://chrome.google.com/webstore/detail/colorzilla/bhlhnicpbhignbdhedgjhgdocnmhomnp">ColorZilla</a>, is one of the most popular Firefox developer extensions with over 5 million downloads, With ColorZilla you can get a color reading from any point in your browser, quickly adjust this color and paste it into another program. You will get an eyedropper, an advanced color picket, the ultimate CSS gradient generator, and much more.</p>
<h3 id="heading-12-wappalyzer">12. Wappalyzer</h3>
<p><a target="_blank" href="https://chrome.google.com/webstore/detail/wappalyzer-technology-pro/gppongmhjkpfnbhagpmjfkannfbllamg">Wappalyzer</a> is more than a CMS detector or framework detector: it uncovers more than a thousand technologies in dozens of categories such as programming languages, analytics, marketing tools, payment processors, CRM, CDN and others. Wappalyzer is more than a CMS detector or framework detector: it uncovers more than a thousand technologies in dozens of categories such as programming languages, analytics, marketing tools, payment processors, CRM, CDN and others.</p>
<h3 id="heading-13-whatruns">13. WhatRuns</h3>
<p><a target="_blank" href="https://chrome.google.com/webstore/detail/whatruns/cmkdbmfndkfgebldhnkbfhlneefdaaip/related">WhatRuns</a> can Discover what runs a website. Frameworks, Analytics Tools, WordPress Plugins, Fonts - you name it. WhatRuns extension is one click away for you to find technologies used on any website you visit. From Developer Tools and Ad Networks to WordPress Plugins and Themes, we detect even new and upcoming tools and services.</p>
<h3 id="heading-14-modheader-modify-http-headers">14. <strong>ModHeader - Modify HTTP headers</strong></h3>
<p>With the help of <a target="_blank" href="https://chrome.google.com/webstore/detail/modheader-modify-http-hea/idgpnmonknjnojddfkpgkljpfnnfcklj">ModHeader</a> extension, you can Modify HTTP request headers, response headers, and redirect URLs. It can Add, modify, and remove request and response headers, Use ModHeader to set X-Forwarded-For, Authorization, Access-Control-Allow-Origin, Content-Security-Policy, and your custom headers, Modify cookies in request/response header, Advanced Content-Security-Policy editor, Redirect URL to another.</p>
<h3 id="heading-15-json-formatter">15. <strong>JSON Formatter</strong></h3>
<p><a target="_blank" href="https://chrome.google.com/webstore/detail/json-formatter/bcjindcccaagfpapjjmafapmmgkkhgoa">JSON Formatter</a>, Makes JSON easy to read with this cool Open source extension. It can auto-format JSON when you load it in a browser tab. It comes with syntax highlighting, clickable URLs, a collapsible tree with indents, and fast loading performance.</p>
<p>This is the end of the list.</p>
<p><strong><em>Any thoughts? Write it down in the comments.</em></strong></p>
<blockquote>
<p>For more such crispy blogs daily, follow Dev.Junction, subscribe to our newsletter and get notified.</p>
</blockquote>
<h2 id="heading-social-links"><strong>Social Links</strong></h2>
<ul>
<li><p><a target="_blank" href="https://www.linkedin.com/in/mnamegaurav/"><strong>LinkedIn</strong></a><strong>:</strong> <a target="_blank" href="https://www.linkedin.com/in/mnamegaurav/"><strong>https://www.linkedin.com/in/mnamegaurav/</strong></a></p>
</li>
<li><p><a target="_blank" href="https://www.youtube.com/devjunction"><strong>YouTube</strong></a><strong>:</strong> <a target="_blank" href="https://www.youtube.com/devjunction"><strong>https://www.youtube.com/devjunction</strong></a></p>
</li>
<li><p><a target="_blank" href="https://gaurav.devjunction.in/"><strong>Website</strong></a><strong>:</strong> <a target="_blank" href="https://gaurav.devjunction.in/"><strong>https://gaurav.devjunction.in/</strong></a></p>
</li>
<li><p><a target="_blank" href="https://github.com/mnamegaurav"><strong>GitHub</strong></a><strong>:</strong> <a target="_blank" href="https://github.com/mnamegaurav"><strong>https://github.com/mnamegaurav</strong></a></p>
</li>
<li><p><a target="_blank" href="https://www.instagram.com/mnamegaurav/"><strong>Instagram</strong></a><strong>:</strong> <a target="_blank" href="https://www.instagram.com/mnamegaurav/"><strong>https://www.instagram.com/mnamegaurav/</strong></a></p>
</li>
<li><p><a target="_blank" href="https://twitter.com/mnamegaurav"><strong>Twitter</strong></a><strong>:</strong> <a target="_blank" href="https://twitter.com/mnamegaurav"><strong>https://twitter.com/mnamegaurav</strong></a></p>
</li>
</ul>
]]></content:encoded></item><item><title><![CDATA[10 Things I Wish I’d Learned Earlier as a Software Developer]]></title><description><![CDATA[Don't try to be a super programmer, nobody expects you to be doing super complicated things in just a few minutes. So stop over-committing your tasks, and analyze the tasks practically by breaking them down into smaller problems.

Searching things on...]]></description><link>https://blog.devjunction.in/10-things-i-wish-id-learned-earlier-as-a-software-developer</link><guid isPermaLink="true">https://blog.devjunction.in/10-things-i-wish-id-learned-earlier-as-a-software-developer</guid><category><![CDATA[Programming Blogs]]></category><category><![CDATA[software development]]></category><category><![CDATA[Software Engineering]]></category><category><![CDATA[Developer]]></category><category><![CDATA[development]]></category><dc:creator><![CDATA[Gaurav Sharma]]></dc:creator><pubDate>Mon, 19 Dec 2022 00:30:42 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1671041167947/zk-EFkSpk.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<ol>
<li><p>Don't try to be a super programmer, nobody expects you to be doing super complicated things in just a few minutes. So stop over-committing your tasks, and analyze the tasks practically by breaking them down into smaller problems.</p>
</li>
<li><p>Searching things on Google is not wrong at all, until or unless you are just copying and pasting the code snippets without understanding a single line. First, try to understand the solution which you have found in your research and then implement it.</p>
</li>
<li><p>If you are worried about something in your job, or not feeling about your tasks, then discuss it with your manager. Your manager/boss can't read your mind, so speak out if you have something in your mind. Most of the time the manager/boss is understanding, and they will help you figure out a solution for your problem.</p>
</li>
<li><p>Seniors are there to help you when needed, I repeat, only "When needed". If you are asking all the things from your senior without even putting in your own effort, then you are doing it wrong with yourself and your senior as well. You will not grow as a Developer if you do not put in your effort, and you will become habitual in asking for help from your seniors, on the other hand, you are just disturbing your seniors by asking too frequently, it affects their productivity, so ask for help only after putting in your efforts.</p>
</li>
<li><p>Things could go wrong in programming, it is a creative and logical thinking process, people miss deadlines, and there is not too much to stress about, just keep your manager/seniors posted on the latest so that they can help you out if needed and figure out an alternative solution if required, but don't let them in darkness.</p>
</li>
<li><p>In Software development, solving a problem is a priority than solving it efficiently. So first your focus should be on just writing a basic solution to that problem and once you are done with a basic solution, you can iterate and come up with a better solution, so first solve the problem, then optimize it.</p>
</li>
<li><p>If you are solving a problem, then your goal should be to write reusable solutions so that the software can be maintainable in the future, and it will eventually make you a great developer.</p>
</li>
<li><p>Teamwork is a crucial part of any organization, if you are working in a team with a fellow developer, and they are helpful, always give credit to your fellow programmers if they have helped you in any way.</p>
</li>
<li><p>If you are in a meeting, or a discussion with your team, then build a habit of taking notes for a minute of the meeting (MOM), It would include the key points discussed, the participants involved, the resolution arrived at etc., transfer the burden of remembering things from your mind to a paper or an app, there are so many tools available these days.</p>
</li>
<li><p>Becoming frustrated is completely normal as a Software developer, the solution you are thinking of for a coding problem doesn't have to always gonna work, there will be errors, bugs and issues. The only thing you can do is keep learning and keep improving your skills, sooner things will get better for you.</p>
</li>
</ol>
<p><strong><em>Any thoughts? Write it down in the comments.</em></strong></p>
<blockquote>
<p>For more such crispy blogs daily, follow Dev.Junction, subscribe to our newsletter and get notified.</p>
</blockquote>
<h2 id="heading-social-links"><strong>Social Links</strong></h2>
<ul>
<li><p><a target="_blank" href="https://www.linkedin.com/in/mnamegaurav/"><strong>LinkedIn</strong></a><strong>:</strong> <a target="_blank" href="https://www.linkedin.com/in/mnamegaurav/"><strong>https://www.linkedin.com/in/mnamegaurav/</strong></a></p>
</li>
<li><p><a target="_blank" href="https://www.youtube.com/devjunction"><strong>YouTube</strong></a><strong>:</strong> <a target="_blank" href="https://www.youtube.com/devjunction"><strong>https://www.youtube.com/devjunction</strong></a></p>
</li>
<li><p><a target="_blank" href="https://gaurav.devjunction.in/"><strong>Website</strong></a><strong>:</strong> <a target="_blank" href="https://gaurav.devjunction.in/"><strong>https://gaurav.devjunction.in/</strong></a></p>
</li>
<li><p><a target="_blank" href="https://github.com/mnamegaurav"><strong>GitHub</strong></a><strong>:</strong> <a target="_blank" href="https://github.com/mnamegaurav"><strong>https://github.com/mnamegaurav</strong></a></p>
</li>
<li><p><a target="_blank" href="https://www.instagram.com/mnamegaurav/"><strong>Instagram</strong></a><strong>:</strong> <a target="_blank" href="https://www.instagram.com/mnamegaurav/"><strong>https://www.instagram.com/mnamegaurav/</strong></a></p>
</li>
<li><p><a target="_blank" href="https://twitter.com/mnamegaurav"><strong>Twitter</strong></a><strong>:</strong> <a target="_blank" href="https://twitter.com/mnamegaurav"><strong>https://twitter.com/mnamegaurav</strong></a></p>
</li>
</ul>
]]></content:encoded></item><item><title><![CDATA[Why Indian government websites are not well designed?]]></title><description><![CDATA[Note: If you are looking for a Full Stack Developer (Django+React), then connect with me on LinkedIn or contact me through my portfolio.
The Indian government is working so hard to make India a digital economy, there used to be a time when websites w...]]></description><link>https://blog.devjunction.in/why-indian-government-websites-are-not-well-designed</link><guid isPermaLink="true">https://blog.devjunction.in/why-indian-government-websites-are-not-well-designed</guid><category><![CDATA[technology]]></category><category><![CDATA[news]]></category><category><![CDATA[Web Development]]></category><category><![CDATA[Programming Blogs]]></category><category><![CDATA[software development]]></category><dc:creator><![CDATA[Gaurav Sharma]]></dc:creator><pubDate>Sun, 18 Dec 2022 00:30:44 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1670950814767/0yFvs1ZTm.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p><strong><em>Note: If you are looking for a Full Stack Developer (Django+React), then connect with me on</em></strong> <a target="_blank" href="https://www.linkedin.com/in/mnamegaurav/"><strong><em>LinkedIn</em></strong></a> <strong><em>or contact me through my</em></strong> <a target="_blank" href="https://gaurav.devjunction.in/"><strong><em>portfolio</em></strong></a><strong><em>.</em></strong></p>
<p>The Indian government is working so hard to make India a digital economy, there used to be a time when websites were slow, buggy and sluggish, but these days things have changed. Not all websites have a bad design, but yes sometimes the UX is very poor.</p>
<p>We'll see some of the reasons in this blog.</p>
<ol>
<li><p>The Indian Government has a Guidelines Manual they call <a target="_blank" href="https://guidelines.india.gov.in/">Guidelines for Indian Government Websites (GIGW)</a> for designing any Government official website. Which was not updated for years but recently in 2019 its second edition was released.</p>
</li>
<li><p>Government websites are not meant for making business, but their purpose is to serve billions of users, where even a disabled person can use the website without any hurdles. So no competition, no innovation.</p>
</li>
<li><p>They focus on a building functional website, which can be accessed even in slow internet areas such as villages, and having a great website means more CSS and JS which they avoid.</p>
</li>
<li><p><a target="_blank" href="https://guidelines.india.gov.in/">Guidelines for Indian Government Websites (GIGW)</a> manual puts so many restrictions to make a functional website, which results in no fresh and out-of-the-box design ideas from Developers/Designers.</p>
</li>
<li><p>The last reason for their bad design is that only a few top-level people decide on the design system and no feedback for such UI/UX from citizens, the actual users.</p>
</li>
</ol>
<p>So here are a few reasons, there can be more of them, but in the end, things are changing and websites are working on better technologies.</p>
<p><strong><em>Any thoughts? Write it down in the comments.</em></strong></p>
<blockquote>
<p><strong><em>For more such crispy blogs daily, follow Dev.Junction, subscribe to our newsletter and get notified.</em></strong></p>
</blockquote>
<h2 id="heading-social-links"><strong>Social Links</strong></h2>
<ul>
<li><p><a target="_blank" href="https://www.linkedin.com/in/mnamegaurav/"><strong>LinkedIn</strong></a><strong>:</strong> <a target="_blank" href="http://linkedin.com/in/mnamegaurav"><strong>linkedin.com/in/mnamegaurav</strong></a></p>
</li>
<li><p><a target="_blank" href="https://www.youtube.com/devjunction"><strong>YouTube</strong></a><strong>:</strong> <a target="_blank" href="http://youtube.com/devjunction"><strong>youtube.com/devjunction</strong></a></p>
</li>
<li><p><a target="_blank" href="https://gaurav.devjunction.in/"><strong>Website</strong></a><strong>:</strong> <a target="_blank" href="http://gaurav.devjunction.in"><strong>gaurav.devjunction.in</strong></a></p>
</li>
<li><p><a target="_blank" href="https://github.com/mnamegaurav"><strong>GitHub</strong></a><strong>:</strong> <a target="_blank" href="http://github.com/mnamegaurav"><strong>github.com/mnamegaurav</strong></a></p>
</li>
<li><p><a target="_blank" href="https://www.instagram.com/mnamegaurav/"><strong>Instagram</strong></a><strong>:</strong> <a target="_blank" href="http://instagram.com/mnamegaurav"><strong>instagram.com/mnamegaurav</strong></a></p>
</li>
<li><p><a target="_blank" href="https://twitter.com/mnamegaurav"><strong>Twitter</strong></a><strong>:</strong> <a target="_blank" href="http://twitter.com/mnamegaurav"><strong>twitter.com/mnamegaurav</strong></a></p>
</li>
</ul>
]]></content:encoded></item><item><title><![CDATA[How to register a model twice in the Django admin?]]></title><description><![CDATA[Note: If you want to read the blog series on Django Admin customization, then click here.

Suppose you have a Book model as given below.
# app_name/models.py

class Book(models.Model):
    ...
    title = models.CharField(max_length=150)
    is_activ...]]></description><link>https://blog.devjunction.in/how-to-register-a-model-twice-in-the-django-admin</link><guid isPermaLink="true">https://blog.devjunction.in/how-to-register-a-model-twice-in-the-django-admin</guid><category><![CDATA[Web Development]]></category><category><![CDATA[webdev]]></category><category><![CDATA[Python]]></category><category><![CDATA[Python 3]]></category><category><![CDATA[Django]]></category><dc:creator><![CDATA[Gaurav Sharma]]></dc:creator><pubDate>Sat, 17 Dec 2022 00:30:42 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1670867367713/owMd3axjn.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<blockquote>
<p>Note: If you want to read the blog <a target="_blank" href="https://blog.devjunction.in/series/django-admin-tips-tricks">series</a> on Django Admin customization, then <a target="_blank" href="https://blog.devjunction.in/series/django-admin-tips-tricks">click here</a>.</p>
</blockquote>
<p>Suppose you have a Book model as given below.</p>
<pre><code class="lang-python"><span class="hljs-comment"># app_name/models.py</span>

<span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">Book</span>(<span class="hljs-params">models.Model</span>):</span>
    ...
    title = models.CharField(max_length=<span class="hljs-number">150</span>)
    is_active = models.BooleanField(default=<span class="hljs-literal">True</span>)
</code></pre>
<p>You might have tried registering a model twice by writing the same code twice, but it gave an error, there is a workaround to register a <code>model</code> twice, you just have to create a <code>proxy</code> model of the same model that you want to register, in this example we are going to create a proxy model of Book and then re-registered it.</p>
<pre><code class="lang-python"><span class="hljs-comment"># app_name/admin.py</span>

<span class="hljs-keyword">from</span> django.contrib <span class="hljs-keyword">import</span> admin
<span class="hljs-keyword">from</span> django.db <span class="hljs-keyword">import</span> models
<span class="hljs-keyword">from</span> app_name.models <span class="hljs-keyword">import</span> Book

<span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">BookProxy</span>(<span class="hljs-params">Book</span>):</span>
    <span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">Meta</span>:</span>
        proxy = <span class="hljs-literal">True</span>

<span class="hljs-meta">@admin.register(Book) # First registration of a Book model in Django admin</span>
<span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">BookAdmin</span>(<span class="hljs-params">admin.ModelAdmin</span>):</span>
    verbose_name = <span class="hljs-string">"Books"</span>

<span class="hljs-meta">@admin.register(BookProxy) # Second registration of a Book model in Django admin</span>
<span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">BookProxyAdmin</span>(<span class="hljs-params">admin.ModelAdmin</span>):</span>
    verbose_name = <span class="hljs-string">"New Books"</span>
</code></pre>
<p><strong><em>Any thoughts? Write it down in the comments.</em></strong></p>
<blockquote>
<p>For more such crispy blogs daily, follow Dev.Junction, subscribe to our newsletter and get notified.</p>
</blockquote>
<h2 id="heading-social-links"><strong>Social Links</strong></h2>
<ul>
<li><p><a target="_blank" href="https://www.linkedin.com/in/mnamegaurav/"><strong>LinkedIn</strong></a><strong>:</strong> <a target="_blank" href="https://www.linkedin.com/in/mnamegaurav/"><strong>https://www.linkedin.com/in/mnamegaurav/</strong></a></p>
</li>
<li><p><a target="_blank" href="https://www.youtube.com/devjunction"><strong>YouTube</strong></a><strong>:</strong> <a target="_blank" href="https://www.youtube.com/devjunction"><strong>https://www.youtube.com/devjunction</strong></a></p>
</li>
<li><p><a target="_blank" href="https://gaurav.devjunction.in/"><strong>Website</strong></a><strong>:</strong> <a target="_blank" href="https://gaurav.devjunction.in/"><strong>https://gaurav.devjunction.in/</strong></a></p>
</li>
<li><p><a target="_blank" href="https://github.com/mnamegaurav"><strong>GitHub</strong></a><strong>:</strong> <a target="_blank" href="https://github.com/mnamegaurav"><strong>https://github.com/mnamegaurav</strong></a></p>
</li>
<li><p><a target="_blank" href="https://www.instagram.com/mnamegaurav/"><strong>Instagram</strong></a><strong>:</strong> <a target="_blank" href="https://www.instagram.com/mnamegaurav/"><strong>https://www.instagram.com/mnamegaurav/</strong></a></p>
</li>
<li><p><a target="_blank" href="https://twitter.com/mnamegaurav"><strong>Twitter</strong></a><strong>:</strong> <a target="_blank" href="https://twitter.com/mnamegaurav"><strong>https://twitter.com/mnamegaurav</strong></a></p>
</li>
</ul>
]]></content:encoded></item><item><title><![CDATA[How to change the number of objects (rows) to show in the Django admin change list view?]]></title><description><![CDATA[Note: If you want to read the blog series on Django Admin customization, then click here.

Suppose you have a Book model as given below.
# app_name/models.py

class Book(models.Model):
    ...
    title = models.CharField(max_length=150)
    is_activ...]]></description><link>https://blog.devjunction.in/how-to-change-the-number-of-objects-rows-to-show-in-the-django-admin-change-list-view</link><guid isPermaLink="true">https://blog.devjunction.in/how-to-change-the-number-of-objects-rows-to-show-in-the-django-admin-change-list-view</guid><category><![CDATA[Web Development]]></category><category><![CDATA[webdev]]></category><category><![CDATA[Python]]></category><category><![CDATA[Python 3]]></category><category><![CDATA[Django]]></category><dc:creator><![CDATA[Gaurav Sharma]]></dc:creator><pubDate>Fri, 16 Dec 2022 00:30:44 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1670867251512/6E9qEnLl1.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<blockquote>
<p>Note: If you want to read the blog <a target="_blank" href="https://blog.devjunction.in/series/django-admin-tips-tricks">series</a> on Django Admin customization, then <a target="_blank" href="https://blog.devjunction.in/series/django-admin-tips-tricks">click here</a>.</p>
</blockquote>
<p>Suppose you have a Book model as given below.</p>
<pre><code class="lang-python"><span class="hljs-comment"># app_name/models.py</span>

<span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">Book</span>(<span class="hljs-params">models.Model</span>):</span>
    ...
    title = models.CharField(max_length=<span class="hljs-number">150</span>)
    is_active = models.BooleanField(default=<span class="hljs-literal">True</span>)
</code></pre>
<p>You can set <code>list_per_page</code> to control how many items appear on each paginated admin change list page. By default, this is set to <code>100</code>.</p>
<pre><code class="lang-python"><span class="hljs-comment"># app_name/admin.py</span>

<span class="hljs-keyword">from</span> django.contrib <span class="hljs-keyword">import</span> admin
<span class="hljs-keyword">from</span> django.db <span class="hljs-keyword">import</span> models
<span class="hljs-keyword">from</span> app_name.models <span class="hljs-keyword">import</span> Book

<span class="hljs-meta">@admin.register(Book)</span>
<span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">BookAdmin</span>(<span class="hljs-params">admin.ModelAdmin</span>):</span>
    ...
    list_per_page = <span class="hljs-number">250</span> <span class="hljs-comment"># You can change this number to mopdify the number of objects(rows)</span>
</code></pre>
<p><strong><em>Any thoughts? Write it down in the comments.</em></strong></p>
<blockquote>
<p>For more such crispy blogs daily, follow Dev.Junction, subscribe to our newsletter and get notified.</p>
</blockquote>
<h2 id="heading-social-links"><strong>Social Links</strong></h2>
<ul>
<li><p><a target="_blank" href="https://www.linkedin.com/in/mnamegaurav/"><strong>LinkedIn</strong></a><strong>:</strong> <a target="_blank" href="https://www.linkedin.com/in/mnamegaurav/"><strong>https://www.linkedin.com/in/mnamegaurav/</strong></a></p>
</li>
<li><p><a target="_blank" href="https://www.youtube.com/devjunction"><strong>YouTube</strong></a><strong>:</strong> <a target="_blank" href="https://www.youtube.com/devjunction"><strong>https://www.youtube.com/devjunction</strong></a></p>
</li>
<li><p><a target="_blank" href="https://gaurav.devjunction.in/"><strong>Website</strong></a><strong>:</strong> <a target="_blank" href="https://gaurav.devjunction.in/"><strong>https://gaurav.devjunction.in/</strong></a></p>
</li>
<li><p><a target="_blank" href="https://github.com/mnamegaurav"><strong>GitHub</strong></a><strong>:</strong> <a target="_blank" href="https://github.com/mnamegaurav"><strong>https://github.com/mnamegaurav</strong></a></p>
</li>
<li><p><a target="_blank" href="https://www.instagram.com/mnamegaurav/"><strong>Instagram</strong></a><strong>:</strong> <a target="_blank" href="https://www.instagram.com/mnamegaurav/"><strong>https://www.instagram.com/mnamegaurav/</strong></a></p>
</li>
<li><p><a target="_blank" href="https://twitter.com/mnamegaurav"><strong>Twitter</strong></a><strong>:</strong> <a target="_blank" href="https://twitter.com/mnamegaurav"><strong>https://twitter.com/mnamegaurav</strong></a></p>
</li>
</ul>
]]></content:encoded></item></channel></rss>