<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Akash Shrivastava on Medium]]></title>
        <description><![CDATA[Stories by Akash Shrivastava on Medium]]></description>
        <link>https://medium.com/@akash.shrivastava136?source=rss-3f5c350d6aaa------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*LmOgmFQAqpDj-eBQmpLlPw.png</url>
            <title>Stories by Akash Shrivastava on Medium</title>
            <link>https://medium.com/@akash.shrivastava136?source=rss-3f5c350d6aaa------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 23 May 2026 15:49:36 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@akash.shrivastava136/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com" rel="hub"/>
        <item>
            <title><![CDATA[Million Tweets and Counting: How Snscrape Can Help You Scrape Big Data on Twitter!]]></title>
            <link>https://medium.com/scalereal/million-tweets-and-counting-how-snscrape-can-help-you-scrape-big-data-on-twitter-5c0240cab4f3?source=rss-3f5c350d6aaa------2</link>
            <guid isPermaLink="false">https://medium.com/p/5c0240cab4f3</guid>
            <category><![CDATA[scraping]]></category>
            <category><![CDATA[data]]></category>
            <category><![CDATA[snscrape]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[twitter]]></category>
            <dc:creator><![CDATA[Akash Shrivastava]]></dc:creator>
            <pubDate>Tue, 04 Apr 2023 07:25:06 GMT</pubDate>
            <atom:updated>2023-04-10T09:50:22.090Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GMVgcavj4mdFRxMwF4kqWw.jpeg" /></figure><p>Hey, there fellow Django and Python enthusiasts! At <a href="https://scalereal.com/">ScaleReal</a> we work extensively on Python/Django Applications and have built a lot of highly scalable applications for various clients of ours.</p><p>While working on such apps, we explored scraping tweets using Snscrape. In this article, we’ll be learning more about it. So, let’s get started!</p><h4>Here’s a list of everything which will be covered in this article:</h4><ol><li><em>What is Snscrape?</em></li><li><em>Why Snscrape?</em></li><li><em>Other available options</em></li><li><em>Installing snscrape</em></li><li><em>Using snscrape from CLI</em></li><li><em>Using snscrape from Python Wrapper</em></li></ol><h3>What is snscrape?</h3><p><a href="https://github.com/JustAnotherArchivist/snscrape"><strong><em>snscrape</em></strong></a> is a scraper for social networking services (SNS). It scrapes things like user profiles, hashtags, or searches and returns the discovered items, e.g. the relevant posts.</p><p>Interestingly, snscrape is not just for scraping tweets but is also used across various social networking sites like Facebook, Instagram, Mastodon, Telegram, Reddit, VKontakte, and Weibo (Sina Weibo).</p><blockquote><strong>Now you might be wondering, is it even legal to scrape data from Twitter?</strong></blockquote><p><strong>Yes</strong>, it is very much legal to scrape data available on Twitter. You can extract publicly available information, but you should be aware that the data extracted might contain personal data.</p><p>Twitter “ tolerates” polite crawlers. However, if the scraped data is publicly posted unconventionally, Twitter can shut down any API access you might have, and potentially take action against your account.</p><h3>Why snscrape?</h3><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgiphy.com%2Fembed%2F3cXmze4Y8igXdnkc3U%2Ftwitter%2Fiframe&amp;display_name=Giphy&amp;url=https%3A%2F%2Fgiphy.com%2Fgifs%2FBTTF-3cXmze4Y8igXdnkc3U&amp;image=https%3A%2F%2Fmedia1.giphy.com%2Fmedia%2Fv1.Y2lkPTc5MGI3NjExZDlvMWljODZrNGt6NTF3cm8wMXB2azE3YzN6NDV3aDU2Y3ZkY3Z5NSZlcD12MV9pbnRlcm5hbF9naWZfYnlfaWQmY3Q9Zw%2F3cXmze4Y8igXdnkc3U%2Fgiphy_s.gif&amp;type=text%2Fhtml&amp;schema=giphy" width="435" height="326" frameborder="0" scrolling="no"><a href="https://medium.com/media/392304c1878800b531f5f6034c4280f3/href">https://medium.com/media/392304c1878800b531f5f6034c4280f3/href</a></iframe><p>If you want to acquire an endless number of tweets, you should use Snscrape. But if you want to use extra features that Snscrape cannot provide (like geolocation, for example), then you should definitely use Tweepy. It is directly integrated with the Twitter API and provides complete functionality.</p><h3><strong>Other available options</strong></h3><h4>1. Tweepy</h4><p><a href="https://github.com/tweepy/tweepy"><strong><em>Tweepy</em></strong></a> is one of the most popular Python libraries to set up access to Twitter. You create a Twitter Developer Account, get credentials and start scraping. It is a great tool for simple automation, creating Twitter bots, or a small school project. However, Tweepy has a scraping limit of 3200 tweets and the farthest time you can go in a week. There is no access to historical data.</p><h4>2. GetOldTweets3</h4><p>Twitter has removed the endpoint the <a href="https://github.com/Mottl/GetOldTweets3"><strong><em>GetOldTweets3</em></strong></a> uses and that makes GOT no longer useful. You will find a LOT of projects on GitHub that used GetOldTweets3 but as of May 4, 2020, there have been no updates to the package to adhere to the revised Twitter guidelines.</p><h4>3. TWINT</h4><p><a href="https://github.com/twintproject/twint"><strong><em>Twint</em></strong></a> is an advanced tool written in Python but Twitter apparently has a more strict device + IP-ban after a certain amount of queries. It’s a hit or miss. A lot of people have issues installing it. The library&#39;s author recommends temporarily using a Dockerfile while the solution becomes clearer. You can know more about TWINT from <a href="https://github.com/twintproject/twint">here</a>.</p><h4>4. Octoparse</h4><p><a href="https://www.octoparse.com/">Octoparse</a> is a paid software that allows you to get data from the web without coding by automatically extracting content from the webpage. Basically, you select a frame on the webpage and scroll down to a point where you see an end to your scraping.</p><h3>Installing snscrape</h3><pre>pip3 install snscrape</pre><p>However, this will not be the developer version. Instead, we’ll be using the below command to download the snscrape dev version:</p><pre>pip3 install git+https://github.com/JustAnotherArchivist/snscrape.git</pre><p>💡 <strong><em>Note</em></strong>: <em>To run git CLI commands, you have to have git installed before running your pip command. If you do not perform the said step, the above command will clone the repository from GitHub but will not execute if git is not installed.</em></p><h3>Using snscrape</h3><p>There are two ways of using snscrape</p><ol><li>Using the command prompt, terminal</li><li>Using Python Wrapper</li></ol><h3>Using snscrape from the command prompt, terminal (Converting JSON files for Python)</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/1*mdSG5Uk_vIrpmYLLrGiu-Q.jpeg" /></figure><p>Whether you run your commands directly in the terminal or through Python, it is a two-step process where you scrape the data into a JSON file and then convert the data to be useable in Python. This section will cover scraping with the CLI commands, then using Pandas to read the JSON file.</p><p>In the example below, we’re scraping 100 tweets from Twitter user @jack. The code is entered in a command prompt/terminal. The code uses several optional arguments explained below.</p><ul><li>-jsonl Outputs the data in a JSON format allowing you to access tweet information. Otherwise, you’ll only receive direct links to the tweets.</li><li>-progress Allows us to get updates from the CLI letting us know the progress of the scraping. It updates every 100 tweets. Does not appear to work when using Python with CLI.</li><li>-max-results # Puts a cap on the number of tweets scraped.</li></ul><pre>snscrape --jsonl --progress --max-results 100 twitter-search &quot;from:jack&quot; &gt; user-tweets.json</pre><h4><strong>Scraping historical tweets from a text search query:</strong></h4><p>In the example below, we’re scraping 500 tweets between June 1, 2022, and July 31, 2022, with the text query “its the elephant” The below code has two new arguments.</p><ul><li>-since Sets lower bound date limit on query</li><li>“until:” Sets upper bound date limit on query</li></ul><pre>snscrape --jsonl --progress --max-results 500 --since 2022-06-01 twitter-search &quot;its the elephant until:2022-07-31&quot; &gt; text-query-tweets.json</pre><p>It’s important to note here that — since is an optional argument you can use, but until: is an operator used inside the twitter-search query. This may seem odd, but it has given me more consistent results than putting both arguments inside the query like below.</p><pre>snscrape --jsonl --progress --max-results 500 twitter-search &quot;its the elephant since:2020-06-01 until:2020-07-31&quot; &gt; text-query-tweets.json</pre><p>You can try both methods and see what gives you better results. However, the first method using — since has been more consistent in giving results so far.</p><h3>Using CLI with Python</h3><p>If you don’t like working directly in the terminal, Python’s OS library allows us to execute CLI commands in Python. It essentially just runs the exact same commands from above but in Python.</p><h4><strong>Scraping a specific Twitter user’s tweets:</strong></h4><pre>import os<br><br># Using OS library to call CLI commands in Python<br>os.system(&quot;snscrape --jsonl --max-results 100 twitter-search &#39;from:jack&#39;&gt; user-tweets.json&quot;)</pre><h4><strong>Scraping historical tweets from a text search query:</strong></h4><pre>import os<br><br># Using OS library to call CLI commands in Python<br>os.system(&quot;snscrape --jsonl --max-results 500 --since 2022-12-01 twitter-search &#39;its the elephant until:2023-01-17&#39; &gt; text-query-tweets.json&quot;)</pre><p>If you find the above code does not work because of an error with the “and”, this might be due to how your OS handles the double/single quotations. The above code works on Windows OS. If you find the above code providing errors hopefully the solution proposed below will help you.</p><pre>import os<br><br># Using OS library to call CLI commands in Python<br>os.system(&quot;snscrape --jsonl --max-results 500 --since 2022-12-01 twitter-search \&quot;its the elephant until:2023-01-17\&quot; &gt; text-query-tweets.json&quot;)</pre><h3>Converting JSON files to be usable in Python</h3><p>Perfect, our data is available in a JSON file but how can we interact with it? The code below shows how we can use the <a href="https://pandas.pydata.org/">Pandas</a> library to convert the JSON files into a data frame so we can interact with it in Python.</p><pre>import pandas as pd<br><br># Reads the json generated from the CLI commands above and creates a pandas dataframe<br>tweets_df = pd.read_json(&#39;text-query-tweets.json&#39;, lines=True)</pre><p>It’s really that simple. You can interact with the JSON data in whatever way you want now that it’s stored as a Pandas data frame. You can export it as a CSV file or Excel file, or modify the data in the Pandas data frame. It’s up to you!</p><h3><strong>2. Using snscrape via Python Wrapper</strong></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Ao8IEMTLozRSSc--" /><figcaption>Photo by <a href="https://unsplash.com/@hiteshchoudhary?utm_source=medium&amp;utm_medium=referral">Hitesh Choudhary</a> on <a href="https://unsplash.com?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>Wrappers around functions in Python allow modifying the behavior of a function or class. Basically, the wrapper wraps a second function to extend the behavior of the wrapped function, without permanently altering it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zo44QT5Z6vMMjwTnp6LWgg.png" /><figcaption>Attributes available through snscrape tweet object (Image Source: Author of snscrape)</figcaption></figure><blockquote>💡<strong>NOTE</strong>: The execution time remains the same, regardless of the number of attributes you declare.</blockquote><h4><strong>Scraping a specific Twitter user’s tweets</strong></h4><p>Using the below code, we can scrape 1000 tweets from Twitter user @jack. We can then pull the DateTime, tweet id, text, and username attributes from the tweet object.</p><pre># importing libraries and packages<br>import snscrape.modules.twitter as sntwitter<br>import pandas<br><br># Creating list to append tweet data <br>tweets_list1 = []<br><br># Using TwitterSearchScraper to scrape data and append tweets to list<br>for i,tweet in enumerate(sntwitter.TwitterSearchScraper(&#39;from:jack&#39;).get_items()): #declare a username <br>    if i&gt;1000: #number of tweets you want to scrape<br>        break<br>    tweets_list1.append([tweet.date, tweet.id, tweet.content, tweet.user.username]) #declare the attributes to be returned<br>    <br># Creating a dataframe from the tweets list above <br>tweets_df1 = pd.DataFrame(tweets_list1, columns=[&#39;Datetime&#39;, &#39;Tweet Id&#39;, &#39;Text&#39;, &#39;Username&#39;])</pre><h4><strong>Scraping tweets from a text search query</strong></h4><p>Using the code below, we are scraping 5000 tweets between January 1, 2022, and May 31, 2022, with the keywords ‘COVID Vaccine’. We can then pull attributes DateTime, tweet id, text, and username from the tweet object.</p><pre>import snscrape.modules.twitter as sntwitter<br>import pandas<br><br># Creating list to append tweet data to<br>tweets_list2 = []<br><br># Using TwitterSearchScraper to scrape data and append tweets to list<br>for i,tweet in enumerate(sntwitter.TwitterSearchScraper(&#39;COVID Vaccine since:2022-01-01 until:2022-05-31&#39;).get_items()):<br>    if i&gt;5000:<br>        break<br>    tweets_list2.append([tweet.date, tweet.id, tweet.content, tweet.user.username])<br>    <br># Creating a dataframe from the tweets list above<br>tweets_df2 = pd.DataFrame(tweets_list2, columns=[&#39;Datetime&#39;, &#39;Tweet Id&#39;, &#39;Text&#39;, &#39;Username&#39;])</pre><p>That’s it from my side devs! 👨‍💻 Thanks for reading!</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgiphy.com%2Fembed%2Fa3IWyhkEC0p32%2Ftwitter%2Fiframe&amp;display_name=Giphy&amp;url=https%3A%2F%2Fgiphy.com%2Fgifs%2Fthank-you-cute-a3IWyhkEC0p32&amp;image=https%3A%2F%2Fmedia0.giphy.com%2Fmedia%2Fv1.Y2lkPTc5MGI3NjExNnZ4eGkybnpsc21pN2dmZGlzZ21oZ3RhdjI2OTN3eGs5NHJqNWJsNyZlcD12MV9pbnRlcm5hbF9naWZfYnlfaWQmY3Q9Zw%2Fa3IWyhkEC0p32%2Fgiphy_s.gif&amp;type=text%2Fhtml&amp;schema=giphy" width="435" height="270" frameborder="0" scrolling="no"><a href="https://medium.com/media/72a9de60c4bbcde56b4de96d775a6adf/href">https://medium.com/media/72a9de60c4bbcde56b4de96d775a6adf/href</a></iframe><p><em>If you enjoyed reading this article, please </em><strong><em>click the 👏 button and share to help others find it!</em></strong><em> Feel free to leave a comment 💬 below. You can connect with me on </em><a href="https://github.com/Akash1362000"><em>GitHub</em></a><em>, </em><a href="https://www.linkedin.com/in/akash136/"><em>LinkedIn</em></a>, and <a href="https://twitter.com/shrivastava136"><em>Twitter</em></a><em>.</em></p><p>Have feedback? Let’s connect <a href="https://www.linkedin.com/in/akash136/"><em>here</em></a>.</p><p><em>~Akash Shrivastava</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5c0240cab4f3" width="1" height="1" alt=""><hr><p><a href="https://medium.com/scalereal/million-tweets-and-counting-how-snscrape-can-help-you-scrape-big-data-on-twitter-5c0240cab4f3">Million Tweets and Counting: How Snscrape Can Help You Scrape Big Data on Twitter!</a> was originally published in <a href="https://medium.com/scalereal">ScaleReal</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The Ultimate Guide to Using Social Login in Django]]></title>
            <link>https://medium.com/scalereal/the-ultimate-guide-to-using-social-login-in-django-f0abe0022ab0?source=rss-3f5c350d6aaa------2</link>
            <guid isPermaLink="false">https://medium.com/p/f0abe0022ab0</guid>
            <category><![CDATA[social-login]]></category>
            <category><![CDATA[google]]></category>
            <category><![CDATA[django]]></category>
            <category><![CDATA[facebook]]></category>
            <category><![CDATA[backend]]></category>
            <dc:creator><![CDATA[Akash Shrivastava]]></dc:creator>
            <pubDate>Thu, 22 Dec 2022 07:29:19 GMT</pubDate>
            <atom:updated>2022-12-22T07:29:19.174Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/650/1*fuhK3rcCWy4KMFhrqF1JLg.jpeg" /></figure><p>Hey, there fellow Djangomers and Pythonistas,</p><p>At <a href="https://scalereal.com/">ScaleReal</a>, we work extensively on Python/Django Applications and have built many highly scalable applications for various clients of ours.</p><p>While working on such apps it’s very important to understand the ins and outs of social logins.</p><p>So, In this article, we’ll learn about Social Logins, why we need them, how it works &amp; how to implement them in Django. So, let’s dive in!</p><h4>Here’s a list of everything which will be covered in this article:</h4><ol><li><em>What is Social Login?</em></li><li><em>Why do we need it?</em></li><li><em>How does Social Login work?</em></li><li><em>Package for implementing social login</em></li><li><em>How to implement Google Social Login in your project?</em></li><li><em>How to implement Facebook Social Login in your project?</em></li></ol><h3>What is Social Login? 🤔</h3><p>A social login is a form of single sign-on using existing information from a social networking service such as Facebook, Twitter, or Google, to sign in to a third-party website instead of creating a new login account specifically for that website.</p><h3>Why do we need it?</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/220/1*f19vQvrS0AEaengdhPmqGg.gif" /></figure><p>Social Login contributes to a more efficient form of user management. The concept of social login authentication involves creating a single sign-on for applications. This means that users can sign up for various applications or websites without repeatedly inputting their credentials.</p><p>The login credentials usually come from a social media platform like Twitter, Facebook, and more, which users can use to automatically input the required credentials. Thus, the process of user authentication will be cut short significantly for users.</p><h3>How does Social Login Work?</h3><p>Social login is a simple process that can be done in just a few steps:</p><ol><li>The user enters an app or site and selects their chosen social network. This usually takes the form of a social login button or “Sign in with [social platform]” links.</li><li>The social network provider receives a login request and authenticates the user. At this stage, users need to accept the access permissions of the app or site.</li><li>The user will get access to the site or app once the social provider has confirmed their identity.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/257/1*m063j442Zm9IEObbeIObEw.png" /><figcaption>Sign in with social platform</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/885/1*yIyJYS8-Y0gQezIz82zlSA.png" /><figcaption>Social Login Sequence Diagram</figcaption></figure><p>If you’re new to OAuth or are hearing this term for the first time, then I recommend reading a bit about OAuth and then proceeding with this article so that you get a better understanding!</p><p>In a nutshell, OAuth is an open standard for access delegation, commonly used as a way for internet users to grant websites or applications access to their information on other websites but without giving them the passwords. You can read more about it in <a href="https://auth0.com/intro-to-iam/what-is-oauth-2">this</a> article by auth0.</p><h3>Package for Implementing Social Login</h3><p>For the scope of this article, we’ll be proceeding with <a href="https://github.com/RealmTeam/django-rest-framework-social-oauth2">django-rest-framework-social-oauth2</a> package.</p><p>The aim of this package is to help set up social authentication for your REST API. It also helps set up your OAuth2 provider. Note that this package relies on <a href="http://python-social-auth.readthedocs.io/">python-social-auth</a> and <a href="https://django-oauth-toolkit.readthedocs.org/">django-oauth-toolkit</a>.</p><h3>How to implement Google Social Login in your project?</h3><ol><li>Create Django App</li><li>Install the above-mentioned package using the following command pip install django-rest-framework-social-oauth2</li><li>Add the following to your INSTALLED_APPS in settings.py</li></ol><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/3e1577fa971186be0b278a0a1404eb25/href">https://medium.com/media/3e1577fa971186be0b278a0a1404eb25/href</a></iframe><p>4. Include social auth URLs in urls.py</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/e70da1ea2127c91cede16c8d19cc5c9e/href">https://medium.com/media/e70da1ea2127c91cede16c8d19cc5c9e/href</a></iframe><p>5. Add these context processors to your TEMPLATES</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/9f02a33321e4fb8a50c2cdc850f67f4c/href">https://medium.com/media/9f02a33321e4fb8a50c2cdc850f67f4c/href</a></iframe><p>6. You can then enable the authentication classes for Django REST Framework by default or per view (add or update the REST_FRAMEWORK and AUTHENTICATION_BACKENDS entries in your settings.py)</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/6abea0b4f8e9707ea32d1c5e472f7786/href">https://medium.com/media/6abea0b4f8e9707ea32d1c5e472f7786/href</a></iframe><p>7. Setup a new application:</p><ul><li>Go to Django admin and add a new Application with the following configuration:</li><li>client_id and client_secret should be left unchanged</li><li>user should be your superuser</li><li>redirect_uris should be left blank</li><li>client_type should be set to public</li><li>authorization_grant_type should be set to &#39;Resource owner password-based&#39;</li><li>name can be set to whatever you&#39;d like</li></ul><p>The basic installation is done, and you can now test the newly configured application.</p><h3>Testing the setup:</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/384/1*9rLLv4uVrE2Vor-TsJd2xg.gif" /><figcaption>Meow testing the setup <strong>😂</strong></figcaption></figure><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/e4247c750bcba7881ef4e30f47064fbf/href">https://medium.com/media/e4247c750bcba7881ef4e30f47064fbf/href</a></iframe><p>Now, to use Google OAuth2 as the authorization backend of your REST API, your settings.py file should look like this:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/0a79b84d27d491f441589fea9de19cb0/href">https://medium.com/media/0a79b84d27d491f441589fea9de19cb0/href</a></iframe><p>You can test these settings by running the following command:</p><pre>curl -X POST -d “grant_type=convert_token&amp;client_id=&lt;django-oauth-generated-client_id&gt;&amp;client_secret=&lt;django-oauth-generated-client_secret&gt;&amp;backend=google-oauth2&amp;token=&lt;google_token&gt;” <a href="http://localhost:8000/auth/convert-token">http://localhost:8000/auth/convert-token</a></pre><p>This request returns an “ access_token” that you should use with every HTTP requests to your REST API. What is happening here is that we are converting a third-party access token (&lt;user_access_token&gt;) to an access token to use with your API and its clients (“access_token”). You should use this token on each and further communication between your system/application and your API to authenticate each request and avoid authenticating with Google every time.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*9pdpG2-f4wDHfNHI" /><figcaption>Photo by <a href="https://unsplash.com/@brett_jordan?utm_source=medium&amp;utm_medium=referral">Brett Jordan</a> on <a href="https://unsplash.com?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>You can get the ID (SOCIAL_AUTH_GOOGLE_OAUTH2_KEY) and secret (SOCIAL_AUTH_GOOGLE_OAUTH2_SECRET) of your app at <a href="https://console.developers.google.com/apis/credentials">Google Developer’s Console</a> and more information on how to create one <a href="https://developers.google.com/identity/protocols/OAuth2">here</a>. For testing purposes, you can use the access token &lt;user_access_token&gt; from <a href="https://developers.google.com/oauthplayground/">OAuth Playground</a>.</p><h3>How to implement Facebook Social Login in your project?</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*fQ5Dn-imm6IZKxAl" /><figcaption>Photo by <a href="https://unsplash.com/@brett_jordan?utm_source=medium&amp;utm_medium=referral">Brett Jordan</a> on <a href="https://unsplash.com?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>To use Facebook as the authorization backend of your REST API, your settings.pyfile should look like this:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/73c4919d4880ae7ec4695e750b2a0a8e/href">https://medium.com/media/73c4919d4880ae7ec4695e750b2a0a8e/href</a></iframe><p>You can test these settings by running the following command:</p><pre>curl -X POST -d &quot;grant_type=convert_token&amp;client_id=&lt;client_id&gt;&amp;client_secret=&lt;client_secret&gt;&amp;backend=facebook&amp;token=&lt;facebook_token&gt;&quot; <a href="http://localhost:8000/auth/convert-token">http://localhost:8000/auth/convert-token</a></pre><p>You can get the ID (SOCIAL_AUTH_FACEBOOK_KEY) and secret (SOCIAL_AUTH_FACEBOOK_SECRET) of your app on <a href="https://developers.facebook.com/apps/">Facebook Developer’s page</a>. For testing purposes, you can use the access token &lt;user_access_token&gt; from <a href="https://developers.facebook.com/tools/accesstoken/">here</a>.</p><p>For more information on how to configure python-social-auth with Facebook visit the docs <a href="http://python-social-auth.readthedocs.io/en/latest/backends/facebook.html">here</a>.</p><h3>Other Social Login Providers</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/960/1*YbTVW_2-Jd7IVqOUcV65Vw.jpeg" /></figure><p>There are a bunch of Social Login providers which are supported by this package. It includes the most popular ones such as Twitter, Github, LinkedIn, Instagram, etc. You can find a complete list of social backends supported by this package and how to configure them in the <a href="https://python-social-auth.readthedocs.io/en/latest/backends/#social-backends">official documentation</a>.</p><p><strong><em>Bonus</em></strong>: <em>You can find the boilerplate code for this article in </em><a href="https://github.com/scalereal/social-login-django-boilerplate"><em>this</em></a><em> repo. It contains basic configurations to get started with Google and Facebook Social Login.</em></p><p>That’s it from my side devs! 👨‍💻</p><p><em>Thanks for reading! If you enjoyed reading this article, please </em><strong><em>click the 👏 button and share to help others find it!</em></strong><em> Feel free to leave a comment 💬 below. You can connect with me </em><a href="https://linktr.ee/Akash_Shrivastava"><em>here</em></a><em>!</em></p><p>Have feedback? Let’s connect <a href="https://www.linkedin.com/in/akash136/"><em>here</em></a>.</p><p><em>~Akash Shrivastava</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f0abe0022ab0" width="1" height="1" alt=""><hr><p><a href="https://medium.com/scalereal/the-ultimate-guide-to-using-social-login-in-django-f0abe0022ab0">The Ultimate Guide to Using Social Login in Django</a> was originally published in <a href="https://medium.com/scalereal">ScaleReal</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Push Notifications through Django]]></title>
            <link>https://medium.com/scalereal/push-notifications-through-django-db528c303b91?source=rss-3f5c350d6aaa------2</link>
            <guid isPermaLink="false">https://medium.com/p/db528c303b91</guid>
            <category><![CDATA[firebase]]></category>
            <category><![CDATA[android]]></category>
            <category><![CDATA[backend]]></category>
            <category><![CDATA[pushnotificationsfirebase]]></category>
            <category><![CDATA[django]]></category>
            <dc:creator><![CDATA[Akash Shrivastava]]></dc:creator>
            <pubDate>Wed, 28 Sep 2022 12:59:07 GMT</pubDate>
            <atom:updated>2022-09-28T12:59:07.287Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*VbnErNCubGvOZYsB" /><figcaption>Photo by <a href="https://unsplash.com/@jamie452?utm_source=medium&amp;utm_medium=referral">Jamie Street</a> on <a href="https://unsplash.com?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>Hey, there fellow Djangomers and Pythonistas,</p><p>At <a href="https://scalereal.com/">ScaleReal</a> we work extensively on Python/Django Applications and have built a lot of highly scalable applications for various clients of ours.</p><p>While working on such apps it’s very important to understand the ins and outs of sending Push Notifications through Django 🔔</p><p>So, In this article, we’ll learn about Push Notifications, why to use them, how it works and how to send Push Notifications to Android and iOS devices. So, let’s dive in!</p><h3>Here’s a list of everything which will be covered in this article:</h3><ol><li><em>What are Push Notifications?</em></li><li><em>Types of Push Notifications</em></li><li><em>Why use them?</em></li><li><em>How does it work?</em></li><li><em>How to use it in your own project?</em></li></ol><h3><strong>What are Push Notifications?</strong></h3><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgiphy.com%2Fembed%2FDpNOlWx7F77IG9stWa%2Ftwitter%2Fiframe&amp;display_name=Giphy&amp;url=https%3A%2F%2Fgiphy.com%2Fgifs%2Fnascar-racing-2021-motorsports-DpNOlWx7F77IG9stWa&amp;image=https%3A%2F%2Fmedia4.giphy.com%2Fmedia%2Fv1.Y2lkPTc5MGI3NjExOW91dmU3YjJzdGJrcmgzZnNtOGpsMmtyOXR5MmlmaWdpaHhtZTczNSZlcD12MV9pbnRlcm5hbF9naWZfYnlfaWQmY3Q9Zw%2FDpNOlWx7F77IG9stWa%2Fgiphy_s.gif&amp;type=text%2Fhtml&amp;schema=giphy" width="435" height="305" frameborder="0" scrolling="no"><a href="https://medium.com/media/f6e3d2f7b6e107a31133e49ca0fb5508/href">https://medium.com/media/f6e3d2f7b6e107a31133e49ca0fb5508/href</a></iframe><p><em>Push notifications</em> at their core are simply a way of alerting users to the information they have opted-in to from apps and services. It’s basically a message that appears on a smartphone. It can only be received by people who have the app installed on their phones. Also, they must have push notifications enabled in order to receive the notifications.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/717/1*P65Rt7ubDu9JTwOAWF6LVQ.png" /><figcaption>Example of a Push Notification</figcaption></figure><h3><strong>Why use Push Notifications? 🤔</strong></h3><ul><li>Push notifications allow you to engage users outside your app</li><li>If used correctly, push notifications can create a far more loyal and active customer base</li><li>The key is not to over-message and only deliver relevant content</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*m01xvrOhMdvZM7o6gd3DrQ.png" /></figure><h3>Top Push Notification Service Providers:</h3><ul><li><a href="https://firebase.google.com/products/in-app-messaging/">Google Firebase</a></li><li><a href="https://onesignal.com/">OneSignal</a></li><li><a href="https://www.leanplum.com/">LeanPlum</a></li><li><a href="https://pushbots.com/">Pushbots</a></li><li><a href="https://pushcrew.com/">PushCrew</a></li><li><a href="https://www.airship.com/">Airship</a></li><li><a href="http://www.catapush.com/">CataPush</a></li><li><a href="https://pushalert.co/">PushAlert</a></li></ul><p>For the scope of this article, we’ll be proceeding with Google Firebase</p><h3>Why use Firebase Push Notifications? 🔥</h3><ul><li>Free to use</li><li>Easy to setup</li><li>Send messages to any device</li><li>Advanced message targeting</li><li>A/B test notifications</li><li>Backed by Google</li></ul><h3>How do Firebase Push Notifications work? 🤨</h3><p><strong>Alternatively Firebase Cloud Messaging (FCM)</strong></p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgiphy.com%2Fembed%2FkQOxxwjjuTB7O%2Ftwitter%2Fiframe&amp;display_name=Giphy&amp;url=https%3A%2F%2Fgiphy.com%2Fgifs%2FkQOxxwjjuTB7O&amp;image=https%3A%2F%2Fmedia4.giphy.com%2Fmedia%2Fv1.Y2lkPTc5MGI3NjExdTU4MHhpeWpmeDM3bngzaGJqNWRqcGE0NHA4cjhlcGltOWlqMnFncCZlcD12MV9pbnRlcm5hbF9naWZfYnlfaWQmY3Q9Zw%2FkQOxxwjjuTB7O%2Fgiphy_s.gif&amp;type=text%2Fhtml&amp;schema=giphy" width="435" height="244" frameborder="0" scrolling="no"><a href="https://medium.com/media/3be16fa0b7ef8d8f48906e7896e097e6/href">https://medium.com/media/3be16fa0b7ef8d8f48906e7896e097e6/href</a></iframe><p>An FCM implementation includes two main components for sending and receiving:</p><ol><li>A trusted environment such as Cloud Functions for Firebase or an app server on which to build, target, and send messages.</li><li>An Apple, Android, or web (JavaScript) client app that receives messages via the corresponding platform-specific transport service.</li></ol><p>You can send messages via the <a href="https://firebase.google.com/docs/cloud-messaging/server#firebase-admin-sdk-for-fcm">Firebase Admin SDK</a> or the <a href="https://firebase.google.com/docs/cloud-messaging/server#choose">FCM server protocols</a>. You can use the <a href="https://console.firebase.google.com/project/_/notification">Notifications composer</a> for testing and to send marketing or engagement messages using powerful built-in targeting and analytics or custom <a href="https://firebase.google.com/docs/projects/import-segments">imported segments</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Ok5LULLSPaZMEAd10V-KWg.png" /></figure><h3>How to set up an FCM project? 👨‍💻</h3><h4><strong>Set up the FCM SDK:</strong></h4><p>Set up Firebase and FCM on your app according to the setup instructions for your platform.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*I0vzoO4YJLMZ_dzrpulSyA.png" /></figure><h4><strong>Develop your client app:</strong></h4><p>Add message handling, topic subscription logic, or other optional features to your client app. During the development, you can easily send test messages from the <a href="https://console.firebase.google.com/project/_/notification">Notifications composer</a>.</p><p><strong>You can connect your Android app to Firebase using one of the following options:</strong></p><ul><li><a href="https://firebase.google.com/docs/android/setup#console">Option 1</a>: Use the Firebase console-setup workflow.</li><li><a href="https://firebase.google.com/docs/android/setup#assistant">Option 2</a>: Use the Android Studio Firebase Assistant (may require additional configuration).</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*CLVwTQmtYm5xDcTy9JBEVQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8_o-7GZtreJhZgysS-Jtsw.png" /></figure><p>By sending a test push notification to our newly created Android App, we can ensure that the Firebase console-setup workflow is done correctly.</p><h4><strong>Develop your app server:</strong></h4><p>Decide whether you want to use the Firebase Admin SDK or one of the server protocols to create your sending logic — logic to authenticate, build send requests, handle responses, and so on. Then build out the logic in your trusted environment. Note that if you want to use upstream messaging from your client applications, you must use XMPP, and that Cloud Function does not support the persistent connection required by XMPP.</p><h3>Next steps</h3><ul><li>Run the <a href="https://github.com/firebase/quickstart-android/tree/master/messaging">Android</a> or <a href="https://github.com/firebase/quickstart-ios/tree/master/messaging/">iOS</a> Quickstart sample. These samples let you run and review code to send a test message to a single device using the Firebase console.</li><li>Try the tutorials for <a href="https://firebase.google.com/docs/cloud-messaging/android/first-message">Android</a> or <a href="https://firebase.google.com/docs/cloud-messaging/ios/first-message">iOS</a>.</li><li>Add Firebase Cloud Messaging to your <a href="https://firebase.google.com/docs/cloud-messaging/android/client">Android</a>, <a href="https://firebase.google.com/docs/cloud-messaging/ios/client">Apple</a>, or <a href="https://firebase.google.com/docs/cloud-messaging/js/client">Web</a> app.</li><li>Set up your trusted environment where you’ll build and send message requests. You can write sending logic using the <a href="https://firebase.google.com/docs/cloud-messaging/server#firebase-admin-sdk-for-fcm">Admin SDK</a>, and readily deploy that code on Cloud Functions for Firebase or other cloud environments managed by Google. Alternatively, you can perform server development using the <a href="https://firebase.google.com/docs/cloud-messaging/server#choose">FCM server protocols</a>.</li><li>Learn more about sending data payloads, setting message priority, and other <a href="https://firebase.google.com/docs/cloud-messaging/concept-options">messaging options</a> that are available with FCM.</li><li>Migrate your existing <a href="http://developers.google.com/cloud-messaging/android/android-migrate-fcm">Android</a> or <a href="http://developers.google.com/cloud-messaging/ios/ios-migrate-fcm">Apple</a> GCM implementation to use Firebase Cloud Messaging.</li></ul><h3>How to Develop your App Server</h3><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgiphy.com%2Fembed%2Fule4vhcY1xEKQ%2Ftwitter%2Fiframe&amp;display_name=Giphy&amp;url=https%3A%2F%2Fgiphy.com%2Fgifs%2Freactionseditor-cat-typing-ule4vhcY1xEKQ&amp;image=https%3A%2F%2Fmedia3.giphy.com%2Fmedia%2Fv1.Y2lkPTc5MGI3NjExMHc3Z3NndWlodWo4ancyZmJxeHBxMGN2bG84Y2VweDBqMmQ1bHQ0diZlcD12MV9pbnRlcm5hbF9naWZfYnlfaWQmY3Q9Zw%2Fule4vhcY1xEKQ%2Fgiphy.gif&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=giphy" width="435" height="435" frameborder="0" scrolling="no"><a href="https://medium.com/media/e665132855f337be5296e139cbea05b2/href">https://medium.com/media/e665132855f337be5296e139cbea05b2/href</a></iframe><ul><li>Create Django App</li><li>Install the following package <a href="https://github.com/jazzband/django-push-notifications"><strong>django-push-notifications</strong></a></li><li>Add secrets to your <strong>settings.py</strong> file</li><li>Run <strong>manage.py migrate</strong> command to apply migrations provided by the package.</li></ul><h3>Configurations to be added in settings.py</h3><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/9ec8c4101a2a9c8641934ee4d08309cc/href">https://medium.com/media/9ec8c4101a2a9c8641934ee4d08309cc/href</a></iframe><ul><li>FCM_API_KEY: Your API key for Firebase Cloud Messaging (You can find it in Project Settings -&gt; Cloud Messaging).</li><li>APNS_CERTIFICATE: Absolute path to your APNS certificate file. Certificates with passphrases are not supported. If the iOS application was built with the &quot;Release&quot; flag, you need to use a production certificate, otherwise, debug. Read more about the <a href="https://github.com/jazzband/django-push-notifications/blob/master/docs/APNS.rst">Generation of an APNS PEM file</a>.</li></ul><h3>Server logic for sending data to FCM via package:</h3><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/845c4740f41ea7ba410da1956746b921/href">https://medium.com/media/845c4740f41ea7ba410da1956746b921/href</a></iframe><p>Once the server logic is in place, you can trigger push notifications at any desired event you wish to. And with this, you have successfully set up and configured your backend 💥</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgiphy.com%2Fembed%2FIB1yI7h963KxMyXR7L%2Ftwitter%2Fiframe&amp;display_name=Giphy&amp;url=https%3A%2F%2Fgiphy.com%2Fgifs%2Fcbs-united-states-of-al-usofal-cbs-IB1yI7h963KxMyXR7L&amp;image=https%3A%2F%2Fmedia3.giphy.com%2Fmedia%2FIB1yI7h963KxMyXR7L%2Fgiphy.gif%3Fcid%3D790b76117cd53952123aeb7c477d9ae0032434730e30959f%26rid%3Dgiphy.gif%26ct%3Dg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=giphy" width="435" height="247" frameborder="0" scrolling="no"><a href="https://medium.com/media/f1263f1f0cd37ed98d088fd4cb954683/href">https://medium.com/media/f1263f1f0cd37ed98d088fd4cb954683/href</a></iframe><h3>Sending Push Notifications via Postman 🚀</h3><ul><li>POST request to <a href="https://fcm.googleapis.com/fcm/send">https://fcm.googleapis.com/fcm/send</a></li><li>Add “Authorization : key=SERVER_KEY_OBTAINED_FROM_FIREBASE” &amp; “Content-Type : application/json” in request headers</li></ul><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/169bf35d97d6b0ff79c44ab143805cf5/href">https://medium.com/media/169bf35d97d6b0ff79c44ab143805cf5/href</a></iframe><figure><img alt="" src="https://cdn-images-1.medium.com/max/940/1*A5Irslzk8JgDR615-ILO-w.png" /><figcaption>Notification sent via Postman</figcaption></figure><h3>Limitations 😬</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/320/1*WpDm2RXxcNN-WsutPoE3WA.gif" /></figure><ul><li>FCM limits push notification payload size to 4096 bytes, so needs to stay within the size limits.</li><li><strong>Notification Throttling</strong> — Can send up to 240 messages/minute and 5,000 messages/hour to a single device. Read more about it <a href="https://firebase.google.com/docs/cloud-messaging/concept-options#throttling-and-scaling">here</a></li></ul><p>That’s it from my side devs! 👨‍💻</p><p><em>Thanks for reading! If you enjoyed reading this article, please </em><strong><em>click the 👏 button and share to help others find it!</em></strong><em> Feel free to leave a comment 💬 below. You can connect with me </em><a href="https://linktr.ee/Akash_Shrivastava"><em>here</em></a><em>!</em></p><p>Have feedback? Let’s connect <a href="https://www.linkedin.com/in/akash136/"><em>here</em></a>.</p><p><em>~Akash Shrivastava</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=db528c303b91" width="1" height="1" alt=""><hr><p><a href="https://medium.com/scalereal/push-notifications-through-django-db528c303b91">Push Notifications through Django</a> was originally published in <a href="https://medium.com/scalereal">ScaleReal</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Everything you need to know about Middleware in Django!]]></title>
            <link>https://medium.com/scalereal/everything-you-need-to-know-about-middleware-in-django-2a3bd3853cd6?source=rss-3f5c350d6aaa------2</link>
            <guid isPermaLink="false">https://medium.com/p/2a3bd3853cd6</guid>
            <category><![CDATA[python]]></category>
            <category><![CDATA[middleware]]></category>
            <category><![CDATA[backend]]></category>
            <category><![CDATA[django]]></category>
            <category><![CDATA[web-development]]></category>
            <dc:creator><![CDATA[Akash Shrivastava]]></dc:creator>
            <pubDate>Thu, 15 Jul 2021 08:58:13 GMT</pubDate>
            <atom:updated>2021-07-15T09:23:29.167Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*8hftGRFSVOIq_5rU" /><figcaption>Photo by <a href="https://unsplash.com/@faisaldada?utm_source=medium&amp;utm_medium=referral">Faisal</a> on <a href="https://unsplash.com?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>Hey, there fellow Djangomers and Pythonistas,</p><p>At <a href="https://scalereal.com">ScaleReal</a> we work extensively on Python/Django Applications and have built a lot of highly scalable applications for various clients of ours.</p><p>While working on such apps it’s very important to understand the ins and outs of Django’s middleware workings.</p><p>So, In this article, we’ll learn about Middleware in Django, why to use them, how it works &amp; how to create custom middleware in Django. So, let’s dive in!</p><h4>Here’s a list of everything which will be covered in this article:</h4><ol><li><em>What is Middleware in Django?</em></li></ol><p>2<em>. How does Middleware work?</em></p><p>3<em>. What are the types of Middleware?</em></p><p>4<em>. How to write a custom Middleware in Django?</em></p><p>5<em>. Things to remember when using middleware</em></p><h4>1. What is Middleware in Django?</h4><p><strong>In Layman terms 👨‍💼</strong>, a Middleware is something which acts as a bridge between two parts of a program or the system that enables communication between them. <strong>In technical terms 👨‍💻,</strong> Middleware is a framework of hooks into Django’s request/response processing. It’s a light, low-level “<strong>plugin</strong>” system for globally altering Django’s input or output. Each middleware component is responsible for doing some specific function.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgiphy.com%2Fembed%2FZeX59ug9zJh1msfgdz%2Ftwitter%2Fiframe&amp;display_name=Giphy&amp;url=https%3A%2F%2Fmedia.giphy.com%2Fmedia%2FZeX59ug9zJh1msfgdz%2Fgiphy.gif&amp;image=https%3A%2F%2Fi.giphy.com%2Fmedia%2FZeX59ug9zJh1msfgdz%2Fgiphy.gif&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=giphy" width="435" height="244" frameborder="0" scrolling="no"><a href="https://medium.com/media/12c0d1fd4e95e81ebd1f42608103ba66/href">https://medium.com/media/12c0d1fd4e95e81ebd1f42608103ba66/href</a></iframe><h4><strong>2. How does Middleware work? 🤔</strong></h4><p>When a user makes a request from your application, a WSGI handler is instantiated, which handles the following things:</p><ul><li>Imports project’s settings.py file and Django exception classes.</li><li>Loads all the middleware classes which are written in MIDDLEWARE tuple located in settings.py file</li><li>Builds list of methods which handle processing of request, view, response &amp; exception.</li><li>Loops through the request methods in order.</li><li>Resolves the requested URL</li><li>Loops through each of the view processing methods</li><li>Calls the view function</li><li>Processes exception methods (if any)</li><li>Loops through each of the response methods in the reverse order from request middleware.</li><li>Builds a return value and makes a call to the callback function.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/602/1*CrgbKz0w7yio7i4LaykOJg.png" /><figcaption>Working of Middleware ⬇⬆</figcaption></figure><h4>3. What are the types of Middleware?</h4><p>There are two types of Middleware in Django:</p><ul><li>Built-in Middleware</li><li>Custom Middleware</li></ul><p><strong>Built-in Middleware</strong> are provided by default in Django when you create your project. You can check the default Middleware in settings.py file of your project.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/ede510dacfbcc588f65100a94a8d65d4/href">https://medium.com/media/ede510dacfbcc588f65100a94a8d65d4/href</a></iframe><p><strong>Custom Middleware</strong> — You can write your own middleware which can be used throughout your project. Let’s see how we can do that!</p><h4>4. How to write a custom Middleware in Django? ✍</h4><ul><li>Create a python package (a folder with __init__.py inside) named as middleware</li><li>Create a file named custom_middleware.py (or anything which you like) and a regular Python function / class in it.</li><li>You can write middleware as a function or as a class whose instances are callable.</li></ul><h4><strong>Function based Middleware:</strong></h4><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/b2f251241a7126942111ce528268f2b8/href">https://medium.com/media/b2f251241a7126942111ce528268f2b8/href</a></iframe><h4><strong>Class based Middleware:</strong></h4><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/1943cfd56d256a8cc2628ae8ece24c3e/href">https://medium.com/media/1943cfd56d256a8cc2628ae8ece24c3e/href</a></iframe><p>Now the final step will be to add your custom middleware in MIDDLEWARE List in settings.py file</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/326d91adacbc5d71edd53c9fbf5f69be/href">https://medium.com/media/326d91adacbc5d71edd53c9fbf5f69be/href</a></iframe><p>All set ✔ Now you can use your custom middleware easily 😁</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgiphy.com%2Fembed%2F3ohzdIuqJoo8QdKlnW%2Ftwitter%2Fiframe&amp;display_name=Giphy&amp;url=https%3A%2F%2Fmedia.giphy.com%2Fmedia%2F3ohzdIuqJoo8QdKlnW%2Fgiphy.gif&amp;image=https%3A%2F%2Fmedia4.giphy.com%2Fmedia%2Fv1.Y2lkPTc5MGI3NjExOXB3dDd4a2pva2JnNW45dnJlZW05anRwbGFycGxkNDg2MXRoOWZrbCZlcD12MV9naWZzX2dpZklkJmN0PWc%2F3ohzdIuqJoo8QdKlnW%2Fgiphy.gif&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=giphy" width="435" height="200" frameborder="0" scrolling="no"><a href="https://medium.com/media/2b6be93d955e20819e24de81eebb003f/href">https://medium.com/media/2b6be93d955e20819e24de81eebb003f/href</a></iframe><h4><strong>Further, let’s understand the special methods of class-based middleware:</strong></h4><ul><li><strong>process_request</strong>: The request object will be created while Django goes through process_request method in each middleware. After that, it resolves which view to be called soon after the request object is created with the help of ROOT_URLCONF key in settings file.</li><li><strong>process_view(request, view_func, view_args, view_kwargs):</strong> request is the HttpRequest object and view_func is the function that is being called. It will be called just before calling the view.</li><li><strong>process_response</strong>: The response will be the final output Django will process after executing the process_response method in each middleware which will be HttpResponse object.</li><li><strong>process_template_response(request, response)</strong>: request is an HttpRequest object. response is the TemplateResponse object (or equivalent) returned by a Django view or by a middleware.</li><li><strong>process_exception(request, exception)</strong>: request is an HttpRequest object. exception is an Exception object raised by the view function. This method is called when the view raises an exception.</li></ul><h4><strong>5. Things to remember when using middleware:</strong></h4><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgiphy.com%2Fembed%2FdZongPVfufls5DcmXr%2Ftwitter%2Fiframe&amp;display_name=Giphy&amp;url=https%3A%2F%2Fmedia.giphy.com%2Fmedia%2FdZongPVfufls5DcmXr%2Fgiphy.gif&amp;image=https%3A%2F%2Fi.giphy.com%2Fmedia%2FdZongPVfufls5DcmXr%2Fgiphy.gif&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=giphy" width="435" height="242" frameborder="0" scrolling="no"><a href="https://medium.com/media/fe8cecc099e8435e0b1517236bf0e635/href">https://medium.com/media/fe8cecc099e8435e0b1517236bf0e635/href</a></iframe><ul><li>Order of middleware is important.</li><li>A middleware only need to extend from class object.</li><li>A middleware is free to implement some of the methods and not implement other methods.</li><li>A middleware may implement process_request but may not implement process_response and process_view.</li></ul><p>That’s it from my side devs! 👨‍💻</p><p><em>Thanks for reading! If you enjoyed reading this article, please </em><strong><em>click the 👏 button and share to help others find it!</em></strong><em> Feel free to leave a comment 💬 below. You can connect with me on </em><a href="https://github.com/Akash1362000"><em>GitHub</em></a><em>, </em><a href="https://www.linkedin.com/in/akash136/"><em>LinkedIn</em></a>, <a href="https://twitter.com/shrivastava136"><em>Twitter</em></a><em>.</em></p><p>Have feedback? Let’s connect <a href="https://www.linkedin.com/in/akash136/"><em>here</em></a>.</p><p><em>~Akash Shrivastava</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2a3bd3853cd6" width="1" height="1" alt=""><hr><p><a href="https://medium.com/scalereal/everything-you-need-to-know-about-middleware-in-django-2a3bd3853cd6">Everything you need to know about Middleware in Django!</a> was originally published in <a href="https://medium.com/scalereal">ScaleReal</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[My Interview Experience for Developer Student Clubs (DSC) Lead — 2020]]></title>
            <link>https://medium.com/dsc-dypcoe/my-interview-experience-for-developer-student-clubs-dsc-lead-2020-e096c11f6bd5?source=rss-3f5c350d6aaa------2</link>
            <guid isPermaLink="false">https://medium.com/p/e096c11f6bd5</guid>
            <category><![CDATA[developer]]></category>
            <category><![CDATA[journey]]></category>
            <category><![CDATA[google]]></category>
            <category><![CDATA[community]]></category>
            <category><![CDATA[developer-student-club]]></category>
            <dc:creator><![CDATA[Akash Shrivastava]]></dc:creator>
            <pubDate>Sat, 10 Apr 2021 13:04:40 GMT</pubDate>
            <atom:updated>2021-07-16T04:55:36.548Z</atom:updated>
            <content:encoded><![CDATA[<h3>My Interview Experience for Developer Student Clubs (DSC) Lead — 2020</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/935/1*PJi-TTqkY0Wzzyjns_CaAg.png" /></figure><p>Hey there 👋, are you interested in becoming a Developer Student Clubs (DSC) Lead? If yes, then you’ve come to the right place. In this article, I’ll share my experience regarding how I got selected as the DSC Lead.<br>But wait, some of you might think that what is DSC 🤔, right? For them, let’s have a look at what exactly DSC is.</p><h3><strong>What are Developer Student Clubs (DSC)?</strong></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*yo1mtcZKByOtMOMS.jpg" /><figcaption>Helping students bridge the gap between theory and practice</figcaption></figure><p><strong>Google Developer Student Clubs (earlier — Developer Student Clubs)</strong> are university-based community groups for students interested in Google developer technologies. Students from all undergraduate or graduate programs with an interest in growing as a developer are welcome. By joining a GDSC, students grow their knowledge in a peer-to-peer learning environment and build solutions for local businesses and their community. Joining a GDSC allows you to Connect, Learn &amp; Grow. To know more about GDSC, read <a href="https://developers.google.com/community/dsc/">here</a>!</p><p>Now, another question which might strike your head is, who am I &amp; why am I writing this article? 🤔</p><h3><strong>Who am I?</strong></h3><p>I am the DSC Lead of <a href="https://dsc.community.dev/dy-patil-college-of-engineering/">D.Y. Patil College of Engineering, Akurdi, Pune</a>.</p><h3><strong>Why am I writing this article?</strong></h3><p>Students from various universities are having doubts regarding how to become the DSC Lead start a Student Developer Community in their college. In this article, I’ll try to cover most of the doubts. But, before that, let me share my experience.</p><p><em>Here’s how it started…</em></p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Ftenor.com%2Fembed%2F4767352&amp;display_name=Tenor&amp;url=https%3A%2F%2Ftenor.com%2Fview%2Fdespicable-me-minions-lets-get-started-happy-excited-gif-4767352&amp;image=https%3A%2F%2Fmedia.tenor.com%2Fr3XdvPsAV3kAAAAN%2Fdespicable-me-minions.png&amp;type=text%2Fhtml&amp;schema=tenor" width="600" height="400" frameborder="0" scrolling="no"><a href="https://medium.com/media/f152eb61b96552df2d9bb54017cba731/href">https://medium.com/media/f152eb61b96552df2d9bb54017cba731/href</a></iframe><p>I got to know about DSC from my senior <a href="https://shreyaspatil.dev/">Shreyas Patil</a>. At that time, I had very less knowledge about DSC. So, I went through their official website. As I was going through the website, I started to develop an interest in this program because I was involved in similar activities in college. The next step was filling out the application form wherein I filled all the necessary &amp; required details and read their terms &amp; conditions thoroughly. At last, there was a section where I had to upload a video with a maximum length of 2 minutes.</p><p><strong>The video included (and must include):</strong></p><ol><li>My Introduction (most important)</li><li>What are my technical interests?</li><li>What am I passionate about?</li><li>What will be the purpose of the DSC Community in my college?</li></ol><p>I made the video &amp; uploaded it on YouTube. You can have a look at my video here 👇</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FGAFNUvVhIPo%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DGAFNUvVhIPo&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FGAFNUvVhIPo%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/20dab6a07c8dd05f4b47ad858fffb3cd/href">https://medium.com/media/20dab6a07c8dd05f4b47ad858fffb3cd/href</a></iframe><p>After the video was uploaded, I submitted the form — in April 2020 (the first half of the month) &amp; got back to my work (becoming a better version of me). I didn’t have any idea regarding the further process. So, I waited.</p><p>After some days, I received an email from Developer Student Clubs (DSC) team that I’ve cleared the first evaluation round. I was happy that I could stand out of the crowd by clearing the first round of evaluation 🥳</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/602/1*GDtwtYWdBuOIDQzLSexlhA.png" /><figcaption>Confirmation Email after clearing the first round of evaluation</figcaption></figure><p>The next step was the interview round for which I had to book an interview appointment.</p><p>I booked the afternoon slot for 27th April 2020.</p><h3><strong>The Interview Day:</strong></h3><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Ftenor.com%2Fembed%2F5135593&amp;display_name=Tenor&amp;url=https%3A%2F%2Ftenor.com%2Fview%2Finterview-suit-gif-5135593&amp;image=https%3A%2F%2Fmedia.tenor.com%2Fimages%2F6d268ee236c2c6482563621a915b170e%2Fraw&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=tenor" width="600" height="400" frameborder="0" scrolling="no"><a href="https://medium.com/media/67bbad825d3760b988bd0dba86a03b8d/href">https://medium.com/media/67bbad825d3760b988bd0dba86a03b8d/href</a></iframe><p>It was a virtual meeting on Google Meet &amp; my interviewer was Sumit Kakkar sir. We both greeted each other, after which he started the interview.</p><p><strong>The following set of questions were asked to me:</strong></p><ol><li>Tell me something about yourself</li><li>What are your technical &amp; non-technical interests?</li><li>Explain the projects which you’ve done so far?</li><li>Have you attended any technical meetups?</li><li>Have you delivered any seminars/sessions? If yes, then how many attendees were present during the seminar?</li><li>Have you worked in a team?</li><li>Why do you want to become a DSC Lead?</li><li>Any other points/achievements that you may have missed out on &amp; want to mention?</li><li>Any questions that you would like to ask?</li></ol><p>The interview was scheduled for 30 minutes, but it lasted for around 20–25 minutes. I answered all the questions will full confidence &amp; enthusiasm. The interview went awesome 🤩</p><blockquote><strong><em>Tip</em></strong><em>: While you book a slot for the interview, you get to know the name of your interviewer. Find out more about him/her on LinkedIn. You may find something interesting which might help you ace your interview round.</em></blockquote><p>The next step was to eagerly wait for the response from the DSC team. One day, while I was scrolling the LinkedIn feed, I came across a post that mentioned that the student was selected as the DSC Lead for his campus located in Pakistan. I came across this post in June 2020. Now, I became very much eager to know the results. After some days (in July), I came to know that students from the India region have been selected as the DSC Lead. I got disappointed a little bit because I thought that all the leads across India have been selected &amp; I didn’t get selected.</p><p>Some days later, I received an email from the DSC team. I opened it 🤞. To my surprise, I got to know that I was selected as the DSC Lead for my campus 🤩</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/598/1*X6rkPC4_cVi2RRFoiKKvaw.png" /><figcaption>DSC Lead Selection Email</figcaption></figure><p>I received the email on 11th August 2020 (after a long wait). I was pretty excited about it as I was the first DSC Lead on my campus. It was one of the greatest achievements for me as I was one among <strong>275 </strong>DSC Leads across <strong>India </strong>&amp; <strong>1220 </strong>DSC Leads across the <strong>globe</strong>!</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Ftenor.com%2Fembed%2F7212866&amp;display_name=Tenor&amp;url=https%3A%2F%2Ftenor.com%2Fview%2Fjonah-hill-yay-greek-aldos-gif-7212866&amp;image=https%3A%2F%2Fmedia.tenor.com%2Fimages%2F05dbf5bf3a3b88275bb045691541dc53%2Ftenor.gif&amp;key=d04bfffea46d4aeda930ec88cc64b87c&amp;type=text%2Fhtml&amp;schema=tenor" width="600" height="400" frameborder="0" scrolling="no"><a href="https://medium.com/media/da8db81d39b7ee0b8e1328924dbff128/href">https://medium.com/media/da8db81d39b7ee0b8e1328924dbff128/href</a></iframe><p>Special thanks to <a href="https://shreyaspatil.dev/">Shreyas Patil</a> for introducing me to this program &amp; guiding me!</p><blockquote><strong>NOTE</strong>: Make sure you double-check your application form before you submit it. Especially, cross-check your college name. A minor mistake in your application form may turn out to be a big mistake for you.</blockquote><h3>Some of the doubts which you might have:</h3><h3>1. How to become a DSC Lead?</h3><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgiphy.com%2Fembed%2FfR79yTeuCA7uHdKCGn%2Ftwitter%2Fiframe&amp;display_name=Giphy&amp;url=https%3A%2F%2Fgiphy.com%2Fgifs%2Fvh1-love-and-hip-hop-fR79yTeuCA7uHdKCGn&amp;image=https%3A%2F%2Fmedia0.giphy.com%2Fmedia%2FfR79yTeuCA7uHdKCGn%2Fgiphy.gif&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=giphy" width="435" height="243" frameborder="0" scrolling="no"><a href="https://medium.com/media/88837782d84aa6f54cae2c06689f96ae/href">https://medium.com/media/88837782d84aa6f54cae2c06689f96ae/href</a></iframe><ul><li>If you are interested in becoming a DSC Lead, the first thing you can do is start working on yourself! Create your GitHub &amp; LinkedIn profile / update it if you already have one. You can have a portfolio website for yourself (optional), which showcases your work, achievements, experience, etc. (here’s my <a href="https://akash1362000.github.io/">portfolio</a>)</li><li>You can reach out to any one of the current DSC Leads &amp; ask them to share their experience &amp; tips. If you have any doubts, you can reach out to me over <a href="https://www.linkedin.com/in/akash136/">LinkedIn</a>, <a href="https://twitter.com/shrivastava136">Twitter</a>. I’ll be happy to help you. 🙂</li></ul><h3>2. Does branch matter?</h3><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgiphy.com%2Fembed%2Fl49JBYPXgnFwDkysw%2Ftwitter%2Fiframe&amp;display_name=Giphy&amp;url=https%3A%2F%2Fgiphy.com%2Fgifs%2Fsnl-jessica-chastain-l49JBYPXgnFwDkysw&amp;image=https%3A%2F%2Fmedia3.giphy.com%2Fmedia%2Fl49JBYPXgnFwDkysw%2Fgiphy.gif&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=giphy" width="435" height="393" frameborder="0" scrolling="no"><a href="https://medium.com/media/1e1ddd1a15408f8e01e8ba695ae35c96/href">https://medium.com/media/1e1ddd1a15408f8e01e8ba695ae35c96/href</a></iframe><p>Nope, the branch doesn’t matter. I am a student of Information Technology (IT) branch but I’ve seen students from non-Computer/IT branches getting selected as DSC Leads. The only thing that matters here is your technical interest &amp; zeal to learn (irrespective of any branch you belong to).</p><p>That’s it from my side folks!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/499/1*EKHCU8Eb3AlfUpXGlImtbg.gif" /></figure><blockquote>I’ll soon be writing another article about what are the activities which I did under DSC &amp; the benefits of getting selected as a DSC Lead.</blockquote><p>Till then, you can visit our <a href="https://dsc.community.dev/dy-patil-college-of-engineering/">community page</a> to know more about the events which we’ve conducted so far.</p><p><em>Thanks for reading! If you enjoyed reading this article, please </em><strong><em>click the 👏 button and share to help others find it!</em></strong><em> Feel free to leave a comment 💬 below. You can connect with me on </em><a href="https://github.com/Akash1362000"><em>GitHub</em></a><em>, </em><a href="https://www.linkedin.com/in/akash136/"><em>LinkedIn</em></a></p><p>Have feedback? Let’s be friends on <a href="https://twitter.com/shrivastava136">Twitter</a>.</p><p><strong><em>All the best for your application 👍</em></strong></p><p><em>~Akash Shrivastava</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e096c11f6bd5" width="1" height="1" alt=""><hr><p><a href="https://medium.com/dsc-dypcoe/my-interview-experience-for-developer-student-clubs-dsc-lead-2020-e096c11f6bd5">My Interview Experience for Developer Student Clubs (DSC) Lead — 2020</a> was originally published in <a href="https://medium.com/dsc-dypcoe">GDSC DYPCOE</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>