<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: It's pronounced W3SHY</title>
    <description>The latest articles on DEV Community by It's pronounced W3SHY (@itsweshy).</description>
    <link>https://dev.to/itsweshy</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F852614%2F8f7a0076-feb5-431f-9525-742ac265ab90.jpg</url>
      <title>DEV Community: It's pronounced W3SHY</title>
      <link>https://dev.to/itsweshy</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/itsweshy"/>
    <language>en</language>
    <item>
      <title>Why ViTest is a Powerful Testing Framework for TypeScript Projects</title>
      <dc:creator>It's pronounced W3SHY</dc:creator>
      <pubDate>Fri, 30 Jun 2023 17:58:24 +0000</pubDate>
      <link>https://dev.to/itsweshy/why-vitest-is-a-powerful-testing-framework-for-typescript-projects-844</link>
      <guid>https://dev.to/itsweshy/why-vitest-is-a-powerful-testing-framework-for-typescript-projects-844</guid>
      <description>&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;Testing is a crucial part of the software development process, ensuring the reliability and stability of your codebase. When it comes to testing JavaScript and TypeScript applications, there are several popular testing frameworks available. One such framework that deserves attention is ViTest. In this article, we will explore why ViTest stands out as a powerful testing framework for TypeScript projects, offering unique advantages over other frameworks like Jest.&lt;/p&gt;

&lt;p&gt;Note that in this article we're not going to dive into the installation, setup and configurations. Let's get into it.&lt;/p&gt;

&lt;h3&gt;
  
  
  1. Minimal Setup and Configuration
&lt;/h3&gt;

&lt;p&gt;ViTest simplifies the setup and configuration process, allowing developers to focus more on writing tests and less on tedious configuration. It provides a minimalistic approach, making it ideal for small to medium-sized projects.&lt;/p&gt;

&lt;h3&gt;
  
  
  2. Concise and Readable Syntax:
&lt;/h3&gt;

&lt;p&gt;ViTest provides a concise and readable syntax, making it easier to write and understand test cases. With its clean and intuitive API, you can express your test expectations in a natural language-like manner. Let's compare a basic test case written in ViTest and Jest:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// ViTest Example&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;test&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;expect&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;vitest&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="nx"&gt;test&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;sum function should return the correct result&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;result&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;sum&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="nx"&gt;expect&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;result&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nx"&gt;toBe&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;

&lt;span class="c1"&gt;// Jest Example&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;sum&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;./math&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="nx"&gt;test&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;sum function should return the correct result&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;result&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;sum&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="nx"&gt;expect&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;result&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nx"&gt;toBe&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;

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

&lt;/div&gt;



&lt;p&gt;As you can see, ViTest's syntax is clean and straightforward, focusing on the essential aspects of the test. This simplicity leads to more readable and maintainable test code.&lt;/p&gt;

&lt;h3&gt;
  
  
  3. TypeScript Integration:
&lt;/h3&gt;

&lt;p&gt;ViTest seamlessly integrates with TypeScript, taking full advantage of its type system to catch errors and provide helpful feedback during testing. You can define and enforce type validations within your test cases, ensuring type correctness throughout your testing process. Here's an example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// ViTest Example&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;test&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;expect&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;vitest&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kr"&gt;interface&lt;/span&gt; &lt;span class="nx"&gt;Person&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;string&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;age&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;number&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nx"&gt;test&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;should validate the type of a person object&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="na"&gt;person&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;Person&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;John&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;age&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;30&lt;/span&gt; &lt;span class="p"&gt;};&lt;/span&gt;
  &lt;span class="nx"&gt;expect&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;person&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nx"&gt;toBeType&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;string&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="nx"&gt;expect&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;person&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;age&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nx"&gt;toBeType&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;number&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;

&lt;span class="c1"&gt;// Jest Example&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;Person&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;./types&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="nx"&gt;test&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;should validate the type of a person object&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="na"&gt;person&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;Person&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;John&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;age&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;30&lt;/span&gt; &lt;span class="p"&gt;};&lt;/span&gt;
  &lt;span class="nx"&gt;expect&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;typeof&lt;/span&gt; &lt;span class="nx"&gt;person&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nx"&gt;toBe&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;string&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="nx"&gt;expect&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;typeof&lt;/span&gt; &lt;span class="nx"&gt;person&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;age&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nx"&gt;toBe&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;number&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;

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

&lt;/div&gt;



&lt;p&gt;By leveraging TypeScript's type checking capabilities, ViTest helps catch potential type-related issues early on, making your tests more robust and reliable.&lt;/p&gt;

&lt;h3&gt;
  
  
  4. Performance and Test Execution Speed:
&lt;/h3&gt;

&lt;p&gt;ViTest is known for its excellent performance and fast test execution speed. It optimizes test execution, ensuring your test suite runs efficiently, even as your codebase grows. This advantage becomes especially significant when dealing with large-scale projects or running extensive test suites.&lt;/p&gt;

&lt;h3&gt;
  
  
  My Final Thoughts
&lt;/h3&gt;

&lt;p&gt;When it comes to testing TypeScript projects, ViTest offers a compelling alternative to other popular testing frameworks like Jest. With its concise syntax, TypeScript integration, and impressive performance, ViTest empowers developers to write clean, readable, and efficient tests. Consider giving ViTest a try for your next TypeScript project and experience the benefits it brings to your testing workflow.&lt;/p&gt;

&lt;p&gt;Remember, testing is a critical aspect of software development, and choosing the right testing framework can significantly impact your project's success. Embrace ViTest and unlock its power for comprehensive and reliable testing in your TypeScript applications.&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;I hope you found the information helpful and informative! If you have any comments or feedback on the article, please feel free to leave them below. I'd love to hear your thoughts and insights on the topic.&lt;/p&gt;

&lt;p&gt;In addition, you can connect with me on &lt;a href="https://www.linkedin.com/in/waithaka-waweru/"&gt;Linkedin&lt;/a&gt; and follow me on &lt;a href="https://twitter.com/ItsWeshy"&gt;Twitter&lt;/a&gt;, I regularly share what I am learning and resources on how improve and skill up.&lt;/p&gt;

&lt;p&gt;Happy testing with ViTest!&lt;/p&gt;

</description>
    </item>
    <item>
      <title>REST APIs with Django Djoser</title>
      <dc:creator>It's pronounced W3SHY</dc:creator>
      <pubDate>Thu, 16 Feb 2023 18:26:08 +0000</pubDate>
      <link>https://dev.to/itsweshy/rest-apis-security-with-django-djoser-4l3c</link>
      <guid>https://dev.to/itsweshy/rest-apis-security-with-django-djoser-4l3c</guid>
      <description>&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;An API(Application Programming Interface), is a set of protocols and methods that allow software applications to communicate with each other. An API specifies how software components should interact with each other, providing a means of communication between different applications or systems. &lt;/p&gt;

&lt;p&gt;A REST API is a type of web API that follows a specific set of architectural principles and constraints to enable communication between software applications. &lt;/p&gt;

&lt;h2&gt;
  
  
  Django Djoser
&lt;/h2&gt;

&lt;p&gt;Django Djoser is a Django package that provides a set of API endpoints and views for handling user authentication and registration. It simplifies the process of building a user authentication system in Django by providing a set of pre-built views and API endpoints for common authentication use cases, such as user registration, email verification, password reset, and more.&lt;/p&gt;

&lt;h2&gt;
  
  
  Lets Get started
&lt;/h2&gt;

&lt;p&gt;To get started with Django Djoser, you'll need to install it using pip:&lt;br&gt;
&lt;code&gt;pip install djoser&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Once installed, you can add Djoser to your Django project by adding it to your INSTALLED_APPS setting in your settings.py file:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;INSTALLED_APPS&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
    &lt;span class="c1"&gt;# ...
&lt;/span&gt;    &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;djoser&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="c1"&gt;# ...
&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;

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

&lt;/div&gt;



&lt;p&gt;Djoser provides a set of API endpoints and views that you can use to handle common user authentication tasks. Here's an overview of some of the most commonly used endpoints:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;/auth/users/&lt;/code&gt;: This endpoint is used for user registration. It expects a POST request with a JSON payload containing the new user's username, email, and password. Once the user is created, a verification email is sent to the user's email address.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;/auth/users/confirm/&lt;/code&gt;: This endpoint is used to confirm a user's email address after registration. It expects a POST request with a JSON payload containing the user's email and the verification code sent in the verification email.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;/auth/token/login/&lt;/code&gt;: This endpoint is used for user login. It expects a POST request with a JSON payload containing the user's username and password. If the credentials are valid, it returns an access token and a refresh token.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;/auth/token/refresh/&lt;/code&gt;: This endpoint is used to refresh an access token. It expects a POST request with a JSON payload containing the refresh token. If the refresh token is valid, it returns a new access token.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;/auth/password/reset/&lt;/code&gt;: This endpoint is used to initiate a password reset request. It expects a POST request with a JSON payload containing the user's email. If the email address is associated with a user account, a password reset email is sent to the user's email address.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;/auth/password/reset/confirm/&lt;/code&gt;: This endpoint is used to confirm a password reset request. It expects a POST request with a JSON payload containing the user's email, the reset token sent in the password reset email, and the new password.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;django.urls&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;path&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;include&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;djoser.views&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="n"&gt;UserCreateView&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;UserActivateView&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;TokenCreateView&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;TokenRefreshView&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;PasswordResetView&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;PasswordResetConfirmView&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="n"&gt;urlpatterns&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
    &lt;span class="c1"&gt;# ...
&lt;/span&gt;    &lt;span class="nf"&gt;path&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;auth/&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nf"&gt;include&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;djoser.urls&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)),&lt;/span&gt;
    &lt;span class="nf"&gt;path&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;auth/&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nf"&gt;include&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;djoser.urls.authtoken&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)),&lt;/span&gt;
    &lt;span class="c1"&gt;# ...
&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;

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

&lt;/div&gt;



&lt;p&gt;This will add all the default Djoser URL patterns to your project, including the ones for the endpoints listed above.&lt;/p&gt;

&lt;h3&gt;
  
  
  Conclusion
&lt;/h3&gt;

&lt;p&gt;In conclusion, Django Djoser is a powerful and flexible authentication package for Django that can save you a lot of time and effort when building a user authentication system. It provides a set of pre-built views and API endpoints for handling common authentication tasks, and is easy to integrate into your existing Django project. Whether you're building a simple web application or a complex enterprise-level system, Djoser can help you get up and running quickly and easily.&lt;/p&gt;

&lt;h3&gt;
  
  
  Resources
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;You can get more information on the &lt;a href="https://djoser.readthedocs.io/en/latest/" rel="noopener noreferrer"&gt;Djoser Documentation&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;Also, I'll be following up with another article that we'll create an application and use Djoser practically.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Connect With Me
&lt;/h3&gt;

&lt;p&gt;Thank you for taking the time to read this article on Django Djoser. I hope you found the information helpful and informative! If you have any comments or feedback on the article, please feel free to leave them below. I'd love to hear your thoughts and insights on the topic.&lt;/p&gt;

&lt;p&gt;In addition, you can connect with me on &lt;a href="https://www.linkedin.com/in/waithaka-waweru/" rel="noopener noreferrer"&gt;Linkedin&lt;/a&gt; and follow me on &lt;a href="https://twitter.com/ItsWeshy" rel="noopener noreferrer"&gt;Twitter&lt;/a&gt;, I regularly share what I am learning and resources on how improve and skill up on Django.&lt;/p&gt;

&lt;p&gt;Happy Coding!&lt;/p&gt;

</description>
      <category>react</category>
      <category>debugging</category>
      <category>discuss</category>
      <category>ui</category>
    </item>
    <item>
      <title>The difference on AbstractUser and AbstractBaseUser</title>
      <dc:creator>It's pronounced W3SHY</dc:creator>
      <pubDate>Wed, 05 Oct 2022 09:34:17 +0000</pubDate>
      <link>https://dev.to/itsweshy/abstractuser-or-abstractbaseuser-1bf7</link>
      <guid>https://dev.to/itsweshy/abstractuser-or-abstractbaseuser-1bf7</guid>
      <description>&lt;h3&gt;
  
  
  Introduction
&lt;/h3&gt;

&lt;p&gt;It is important to understand the difference between AbstractUser and AbstractBaseUser when you are a Django developer. I am hoping that this article will help you answer the confusions the two come with.&lt;/p&gt;

&lt;h3&gt;
  
  
  First, we explain…
&lt;/h3&gt;

&lt;h4&gt;
  
  
  AbstractUser
&lt;/h4&gt;

&lt;p&gt;&lt;em&gt;AbstractUser&lt;/em&gt; class initially has 11 fields, the same as default "User" class as shown below and for the subclass of AbstractUser class, you can add new fields, change and remove initial fields. &lt;/p&gt;

&lt;p&gt;Keep it in mind that "username" and "email" fields in the initial fields of &lt;em&gt;AbstractUser&lt;/em&gt; class are special and only "username" fields have Unique Constraint.&lt;br&gt;
These are the initial fields of &lt;em&gt;AbstractUser&lt;/em&gt; class which default "User" class has as shown below:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="nb"&gt;id&lt;/span&gt; 
&lt;span class="n"&gt;password&lt;/span&gt; 
&lt;span class="n"&gt;last_login&lt;/span&gt; 
&lt;span class="n"&gt;is_superuser&lt;/span&gt; 
&lt;span class="n"&gt;username&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;Special&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;Unique&lt;/span&gt; &lt;span class="n"&gt;Constraint&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; 
&lt;span class="n"&gt;first_name&lt;/span&gt; 
&lt;span class="n"&gt;last_name&lt;/span&gt; 
&lt;span class="n"&gt;email&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;Special&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; 
&lt;span class="n"&gt;is_staff&lt;/span&gt; 
&lt;span class="n"&gt;is_active&lt;/span&gt; 
&lt;span class="n"&gt;date_joined&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  AbstractBaseUser
&lt;/h3&gt;

&lt;p&gt;&lt;em&gt;AbstractBaseUser&lt;/em&gt; class initially has 3 fields as shown below and for the subclass of &lt;em&gt;AbstractBaseUser&lt;/em&gt; class, you can add new fields, change and remove initial fields the same as &lt;em&gt;AbstractUser&lt;/em&gt; class. &lt;/p&gt;

&lt;p&gt;These are the initial fields of &lt;em&gt;AbstractBaseUser&lt;/em&gt; class as shown below:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;id 
password 
last_login
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  From what we have seen...
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;AbstractUser&lt;/strong&gt; is a full User model, complete with fields which you’re probably already used to. It's an abstract class so that you can inherit from it and add your own profile fields required for your database and methods. It’s a change of schema of the database.
The fields you might add are like date_of_birth, location to the User model which means you will get the complete field which was there by default plus your added fields.
&lt;/li&gt;
&lt;/ul&gt;

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

&lt;span class="c1"&gt;# TODO: First you import the AbstractUser from django auth model 
#  and inherit it with the Custom User model
&lt;/span&gt;
&lt;span class="c1"&gt;# Create your models here
&lt;/span&gt;&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;CustomUser&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;AbstractUser&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="n"&gt;date_of_birth&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;models&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;DateTimeField&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
    &lt;span class="n"&gt;location&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;models&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;CharField&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;max_length&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;100&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;nickname&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;models&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;CharField&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;max_length&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;100&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The above example you will get all the fields of the User model, additionally the fields that we defined here: date_of_birth, location &amp;amp; nickname.&lt;br&gt;
&lt;br&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;AbstractBaseUser&lt;/strong&gt; only contains the authentication functionality: you have to supply them when you subclass. It makes fewer assumptions. 

&lt;ul&gt;
&lt;li&gt;You have to tell it what field will represent the username, the fields that are required, and how those users will be managed.
&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="nn"&gt;django.db&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;models&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="nn"&gt;django.contrib.auth.models&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;AbstractBaseUser&lt;/span&gt;

&lt;span class="c1"&gt;# TODO: First you import the AbstractBaseUser from django auth model 
#  and inherit it with the Custom User model
&lt;/span&gt;
&lt;span class="c1"&gt;# Create your models here
&lt;/span&gt;&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;CustomUser&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;AbstractBaseUser&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="n"&gt;email&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;models&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;EmailField&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;max_length&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;256&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;unique&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="bp"&gt;True&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;verbose_name&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;'email'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;date_of_birth&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;models&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;DateTimeField&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
    &lt;span class="n"&gt;location&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;models&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;CharField&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;max_length&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;100&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;is_active&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;models&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;BooleanField&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;default&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="bp"&gt;True&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;is_admin&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;models&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;BooleanField&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;default&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="bp"&gt;False&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

    &lt;span class="n"&gt;USERNAME_FIELD&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s"&gt;'email'&lt;/span&gt;
    &lt;span class="n"&gt;REQUIRED_FIELDS&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s"&gt;'location'&lt;/span&gt;

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

&lt;/div&gt;


&lt;p&gt;Keep it in mind that as you've already noticed, &lt;em&gt;AbstractBaseUser&lt;/em&gt; class also has "USERNAME_FIELD" and by default, no field is set to "USERNAME_FIELD" so you need to set one existing field to it as shown above otherwise there is an error. In addition, no fields are set to "REQUIRED_FIELDS"&lt;/p&gt;

&lt;p&gt;It is important to note that you can also set email as your unique identifier by using &lt;em&gt;AbstractUser&lt;/em&gt;, this can be done by setting username = None and USERNAME_FIELD = 'email' as shown below&lt;br&gt;
&lt;/p&gt;

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

&lt;span class="c1"&gt;# TODO: First you import the AbstractUser from django auth model 
#  and inherit it with the Custom User model
&lt;/span&gt;
&lt;span class="c1"&gt;# Create your models here
&lt;/span&gt;&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;CustomUser&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;AbstractUser&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="n"&gt;username&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="bp"&gt;None&lt;/span&gt;
    &lt;span class="n"&gt;email&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;models&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;EmailField&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;max_length&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;256&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;unique&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="bp"&gt;True&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;verbose_name&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;'email'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

    &lt;span class="n"&gt;USERNAME_FIELD&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s"&gt;'email'&lt;/span&gt;
    &lt;span class="n"&gt;REQUIRED_FIELDS&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s"&gt;'location'&lt;/span&gt;

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

&lt;/div&gt;





&lt;h2&gt;
  
  
  In Conclusion, which one should you use?
&lt;/h2&gt;

&lt;p&gt;Main difference basically lies on Use-case. Say for example you no longer need the existing User class provided by Django and you only care about authentication functionalities provided by the User class and your own custom fields. In that case, you should use &lt;em&gt;AbstractBaseUser&lt;/em&gt;. In another case, you want to use existing User Fields and functionalities but on top of that you would like to add some extra fields and methods. In that case, you should use &lt;em&gt;AbstractUser&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;&lt;br&gt;&lt;br&gt;
For feedback, reach out on &lt;a href="https://twitter.com/ItsWeshy"&gt;Twitter&lt;/a&gt;&lt;/p&gt;

</description>
      <category>django</category>
      <category>beginners</category>
      <category>codenewbie</category>
      <category>hacktoberfest</category>
    </item>
    <item>
      <title>How to Deploy Django Applications on Heroku</title>
      <dc:creator>It's pronounced W3SHY</dc:creator>
      <pubDate>Thu, 19 May 2022 18:23:36 +0000</pubDate>
      <link>https://dev.to/itsweshy/how-to-deploy-django-applications-on-heroku-5bl3</link>
      <guid>https://dev.to/itsweshy/how-to-deploy-django-applications-on-heroku-5bl3</guid>
      <description>&lt;h3&gt;
  
  
  Install Heroku CLI
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://signup.heroku.com/login"&gt;Sign Up&lt;/a&gt; to Heroku&lt;/p&gt;

&lt;p&gt;After installing the Heroku CLI, open a terminal and login to your account:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ heroku login
heroku: Press any key to open up the browser to login or q to exit: 
heroku: Waiting for login... ⣻
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You're redirected to your browser and you login to Heroku with Heroku CLI and get a success message on your terminal&lt;/p&gt;

&lt;h3&gt;
  
  
  Creating App
&lt;/h3&gt;

&lt;p&gt;First make sure you are in the root directory of the repository you want to deploy&lt;/p&gt;

&lt;p&gt;Next create the heroku app from the terminal:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;heroku create &amp;lt;your-app&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Preparing the Application
&lt;/h3&gt;

&lt;h4&gt;
  
  
  Assumptions
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;You're familiar with the basics of Django. &lt;em&gt;eg. concept of apps, settings, urls, basics of databases.&lt;/em&gt;
&lt;/li&gt;
&lt;li&gt;You have a Django application that you want to deploy to Heroku.&lt;/li&gt;
&lt;li&gt;You are familiar with virtual environments&lt;/li&gt;
&lt;li&gt;Your deployment Database is &lt;strong&gt;PostgreSQL&lt;/strong&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;You will have to install several packages that will come in handy:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;django-heroku &lt;code&gt;pip install django-heroku&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;gunicorn &lt;code&gt;pip install gunicorn&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;decouple &lt;code&gt;pip install python-decouple&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;DATABASE_URL &lt;code&gt;pip install dj-database-url&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;whitenoise &lt;code&gt;pip install whitenoise&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;You will then add the following files in your application&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Add a &lt;code&gt;Procfile&lt;/code&gt; in the project root;&lt;/li&gt;
&lt;li&gt;Add &lt;code&gt;requirements.txt&lt;/code&gt; file with all the requirements in the project root;&lt;/li&gt;
&lt;li&gt;Add &lt;code&gt;requirements.txt&lt;/code&gt; with &lt;code&gt;pip freeze &amp;gt; requirements.txt&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;A &lt;code&gt;runtime.txt&lt;/code&gt; to specify the correct Python version in the project root;&lt;/li&gt;
&lt;li&gt;Configure &lt;code&gt;whitenoise&lt;/code&gt; to serve static files.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Now we go through each one of them&lt;/p&gt;

&lt;h5&gt;
  
  
  &lt;u&gt;Procfile&lt;/u&gt;
&lt;/h5&gt;

&lt;p&gt;Heroku apps include a Procfile that specifies the commands that are executed by the app’s dynos.&lt;br&gt;
Create a file named Procfile in the project root with the following content:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;web: gunicorn your_project_name.wsgi
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h5&gt;
  
  
  &lt;u&gt;runtime.txt&lt;/u&gt;
&lt;/h5&gt;

&lt;p&gt;This file contains the python version you are using for heroku to use, create &lt;code&gt;runtime.txt&lt;/code&gt; in your project root and add your python version in the following format:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;python-3.8.12
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can specify which runtime to use for your app. List of &lt;a href="https://devcenter.heroku.com/articles/python-runtimes"&gt;Heroku Runtimes&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Configuring Whitenoise: Django Static Files settings
&lt;/h3&gt;

&lt;p&gt;It turns out django does not support serving static files in production. However, WhiteNoise project can integrate into your Django application, and was designed with exactly this purpose in mind.&lt;/p&gt;

&lt;p&gt;Lets first configure static related parameter in &lt;code&gt;settings.py&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))

# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/1.9/howto/static-files/

STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles')
STATIC_URL = '/static/'

# Extra places for collectstatic to find static files.
STATICFILES_DIRS = (
    os.path.join(BASE_DIR, 'static'),
)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then add this line of code in the &lt;code&gt;middleware section&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;MIDDLEWARE_CLASSES = (
    # Simplified static file serving.
    # https://warehouse.python.org/project/whitenoise/
    'whitenoise.middleware.WhiteNoiseMiddleware',
    ...
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Add the following setting to settings.py in the static files section to enable gzip functionality.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# Simplified static file serving.
# https://warehouse.python.org/project/whitenoise/

STATICFILES_STORAGE = 'whitenoise.storage.CompressedManifestStaticFilesStorage'

# configuring the location for media
MEDIA_URL = '/media/'
MEDIA_ROOT = os.path.join(BASE_DIR, 'media')

# Configure Django App for Heroku.
django_heroku.settings(locals())
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  python-decouple and dj-database-url
&lt;/h3&gt;

&lt;p&gt;Python Decouple is a must have app if you are developing with Django. It’s important to keep your application credentials like API Keys, tokens and passwords.&lt;br&gt;
dj-database-url is a simple Django utility that holds your Postgres database url&lt;/p&gt;
&lt;h4&gt;
  
  
  &lt;u&gt;.env&lt;/u&gt;
&lt;/h4&gt;

&lt;p&gt;Firts create a &lt;code&gt;.env&lt;/code&gt; file and add it to &lt;code&gt;.gitignore&lt;/code&gt;so you don’t commit any sensitive data to your repository. Below is an example of configurations you can add to the &lt;code&gt;.env&lt;/code&gt; file.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# An example, don't share your.env settings
SECRET_KEY='342s(s(!hsjd998sde8$=o4$3m!(o+kce2^97kp6#ujhi'
DEBUG=True
DB_NAME='db_name'
DB_USER='user'
DB_PASSWORD='db_password'
DB_HOST='127.0.0.1'
MODE='dev'
ALLOWED_HOSTS='&amp;lt;app name in heroku&amp;gt;.herokuapp.com'
DISABLE_COLLECTSTATIC=1
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We then edit settings.py to enable decouple to use the .env configurations.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import os
import django_heroku
import dj_database_url
from decouple import config,Csv

MODE=config("MODE", default="dev")
SECRET_KEY = config('SECRET_KEY')
DEBUG = config('DEBUG', default=False, cast=bool)
# development
if config('MODE')=="dev":
   DATABASES = {
       'default': {
           'ENGINE': 'django.db.backends.postgresql_psycopg2',
           'NAME': config('DB_NAME'),
           'USER': config('DB_USER'),
           'PASSWORD': config('DB_PASSWORD'),
           'HOST': config('DB_HOST'),
           'PORT': '',
       }

   }
# production
else:
   DATABASES = {
       'default': dj_database_url.config(
           default=config('DATABASE_URL')
       )
   }

db_from_env = dj_database_url.config(conn_max_age=500)
DATABASES['default'].update(db_from_env)

ALLOWED_HOSTS = config('ALLOWED_HOSTS', cast=Csv())
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Deploying the app to Heroku
&lt;/h3&gt;

&lt;p&gt;Create a postgres addon to your Heroku app&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;heroku addons:create heroku-postgresql:hobby-dev
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Next we log in to &lt;a href="https://dashboard.heroku.com/apps"&gt;Heroku dashboard &lt;/a&gt; to access our app and configure it&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--KOUdBdoq--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/1t81f7kp8snf4a6557or.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--KOUdBdoq--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/1t81f7kp8snf4a6557or.png" alt="Heroku dashboard" width="800" height="349"&gt;&lt;/a&gt;&lt;br&gt;
Add all your configurations in &lt;code&gt;.env&lt;/code&gt; file directly to Heroku by running this command.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;heroku config:set $(cat .env | sed '/^$/d; /#[[:print:]]*$/d')
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Remember to first set DEBUG to False and confirm that you have added all the configuration variables needed. &lt;em&gt;Click on the Settings menu and then on the button Reveal Config Vars&lt;/em&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  Pushing to Heroku
&lt;/h4&gt;

&lt;p&gt;Confirm that your app is running as expected before pushing. Runtime errors will cause deployment to fail so make sure you have no bugs and you have all the following; &lt;code&gt;Procfile&lt;/code&gt;, &lt;code&gt;requirements.txt&lt;/code&gt; with all required packages and &lt;code&gt;runtime.txt&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Commit all the changes we have made and then:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git push heroku master
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;If you are using main as the branch, change master to main&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If you did everything correctly then the deployment should be done after a while with an output like this&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Enumerating objects: 94, done.
Counting objects: 100% (94/94), done.
Delta compression using up to 8 threads.
Compressing objects: 100% (84/84), done.
Writing objects: 100% (94/94), 3.35 MiB | 630.00 KiB/s, done.
Total 94 (delta 24), reused 0 (delta 0)
remote: Compressing source files... done.
remote: Building source:
remote: 
remote: -----&amp;gt; Python app detected
remote: -----&amp;gt; Installing python-3.6.6
remote: -----&amp;gt; Installing pip
remote: -----&amp;gt; Installing requirements with pip
remote:        Collecting config==0.3.9 (from -r /tmp/build_19aebf8f25d534a39e73b13219af9927/requirements.txt (line 1))
remote:          Downloading https://files.pythonhosted.org/packages/0a/46/186ac016f3175211ec9bb4208579bc6dc9dd7dc882790d9f281533b83b0f/config-0.3.9.tar.gz
remote:        Collecting dj-database-url==0.5.0 (from -r /tmp/build_19aebf8f25d534a39e73b13219af9927/requirements.txt (line 2))
remote:          Downloading https://files.pythonhosted.org/packages/d4/a6/4b8578c1848690d0c307c7c0596af2077536c9ef2a04d42b00fabaa7e49d/dj_database_url-0.5.0-py2.py3-none-any.whl
remote:        Collecting Django==1.11 (from -r /tmp/build_19aebf8f25d534a39e73b13219af9927/requirements.txt (line 3))
remote:          Downloading https://files.pythonhosted.org/packages/47/a6/078ebcbd49b19e22fd560a2348cfc5cec9e5dcfe3c4fad8e64c9865135bb/Django-1.11-py2.py3-none-any.whl (6.9MB)
remote:        Collecting django-bootstrap3==10.0.1 (from -r /tmp/build_19aebf8f25d534a39e73b13219af9927/requirements.txt (line 4))
remote:          Downloading https://files.pythonhosted.org/packages/18/a8/f12d8491155c7f237084b883b8600faf722e3a46e54f17a25103b0fb9641/django-bootstrap3-10.0.1.tar.gz (40kB)
remote:        Collecting django-heroku==0.3.1 (from -r /tmp/build_19aebf8f25d534a39e73b13219af9927/requirements.txt (line 5))
remote:          Downloading https://files.pythonhosted.org/packages/59/af/5475a876c5addd5a3494db47d9f7be93cc14d3a7603542b194572791b6c6/django_heroku-0.3.1-py2.py3-none-any.whl
remote:        Collecting gunicorn==19.9.0 (from -r /tmp/build_19aebf8f25d534a39e73b13219af9927/requirements.txt (line 6))
remote:          Downloading https://files.pythonhosted.org/packages/8c/da/b8dd8deb741bff556db53902d4706774c8e1e67265f69528c14c003644e6/gunicorn-19.9.0-py2.py3-none-any.whl (112kB)
remote:        Collecting Pillow==5.2.0 (from -r /tmp/build_19aebf8f25d534a39e73b13219af9927/requirements.txt (line 7))
remote:          Downloading https://files.pythonhosted.org/packages/d1/24/f53ff6b61b3d728b90934bddb4f03f8ab584a7f49299bf3bde56e2952612/Pillow-5.2.0-cp36-cp36m-manylinux1_x86_64.whl (2.0MB)
remote:        Collecting psycopg2==2.7.5 (from -r /tmp/build_19aebf8f25d534a39e73b13219af9927/requirements.txt (line 8))
remote:          Downloading https://files.pythonhosted.org/packages/5e/d0/9e2b3ed43001ebed45caf56d5bb9d44ed3ebd68e12b87845bfa7bcd46250/psycopg2-2.7.5-cp36-cp36m-manylinux1_x86_64.whl (2.7MB)
remote:        Collecting python-decouple==3.1 (from -r /tmp/build_19aebf8f25d534a39e73b13219af9927/requirements.txt (line 9))
remote:          Downloading https://files.pythonhosted.org/packages/9b/99/ddfbb6362af4ee239a012716b1371aa6d316ff1b9db705bfb182fbc4780f/python-decouple-3.1.tar.gz
remote:        Collecting pytz==2018.5 (from -r /tmp/build_19aebf8f25d534a39e73b13219af9927/requirements.txt (line 10))
remote:          Downloading https://files.pythonhosted.org/packages/30/4e/27c34b62430286c6d59177a0842ed90dc789ce5d1ed740887653b898779a/pytz-2018.5-py2.py3-none-any.whl (510kB)
remote:        Collecting whitenoise==3.3.1 (from -r /tmp/build_19aebf8f25d534a39e73b13219af9927/requirements.txt (line 11))
remote:          Downloading https://files.pythonhosted.org/packages/0c/58/0f309a821b9161d0e3a73336a187d1541c2127aff7fdf3bf7293f9979d1d/whitenoise-3.3.1-py2.py3-none-any.whl
remote:        Installing collected packages: config, dj-database-url, pytz, Django, django-bootstrap3, whitenoise, psycopg2, django-heroku, gunicorn, Pillow, python-decouple
remote:          Running setup.py install for config: started
remote:            Running setup.py install for config: finished with status 'done'
remote:          Running setup.py install for django-bootstrap3: started
remote:            Running setup.py install for django-bootstrap3: finished with status 'done'
remote:          Running setup.py install for python-decouple: started
remote:            Running setup.py install for python-decouple: finished with status 'done'
remote:        Successfully installed Django-1.11 Pillow-5.2.0 config-0.3.9 dj-database-url-0.5.0 django-bootstrap3-10.0.1 django-heroku-0.3.1 gunicorn-19.9.0 psycopg2-2.7.5 python-decouple-3.1 pytz-2018.5 whitenoise-3.3.1
remote: 
remote: -----&amp;gt; Discovering process types
remote: 
remote: -----&amp;gt; Compressing...
remote:        Done: 56.3M
remote: -----&amp;gt; Launching...
remote:        Released v6
remote:        https://mtr1bune.herokuapp.com/ deployed to Heroku
remote: 
remote: Verifying deploy... done.
To https://git.heroku.com/mtr1bune.git
 * [new branch]      master -&amp;gt; master
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Run Migrations
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;heroku run python manage.py migrate
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If you wish to push your postgres database data to Heroku then run&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;heroku pg:reset
heroku pg:push &amp;lt;The name of the db in the local psql&amp;gt; DATABASE_URL --app &amp;lt;heroku-app&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can the open the app in your browse.&lt;/p&gt;

&lt;h4&gt;
  
  
  Last comment
&lt;/h4&gt;

&lt;p&gt;Don't beat yourself up when you find it challenging to memorize language or library syntax. They have documentation for a reason, so feel free to reference it. The syntax will stick to your memory on frequent use.💯✍️&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--QS4IzK2O--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/emumt6zkh7bq31iduycm.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--QS4IzK2O--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/emumt6zkh7bq31iduycm.png" alt="tweet" width="800" height="353"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Mastering Python for Web Development</title>
      <dc:creator>It's pronounced W3SHY</dc:creator>
      <pubDate>Sun, 01 May 2022 08:54:41 +0000</pubDate>
      <link>https://dev.to/itsweshy/mastering-python-for-web-development-57g7</link>
      <guid>https://dev.to/itsweshy/mastering-python-for-web-development-57g7</guid>
      <description>&lt;h2&gt;
  
  
  Into
&lt;/h2&gt;

&lt;p&gt;Everybody’s online today. It doesn’t matter if it’s about commerce, government, gaming, banking, social media, everybody who has a connection is on the internet.&lt;/p&gt;

&lt;p&gt;Consequently, there’s a greater demand for engaging, user-friendly websites to interact with. That’s why the IT world turns to web development to get those well-designed websites created and launched.&lt;/p&gt;

&lt;p&gt;Python is one of the most popular programming languages available. Today, we are exploring Python web development, what it is, the pros and cons of using Python for web development, and how to prepare yourself to use Python in a web development project.&lt;/p&gt;

&lt;p&gt;But first, a quick word about the &lt;a href="https://dev.to/itsweshy/python-101-the-ultimate-python-tutorial-for-beginners-1bci"&gt;Python Language&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Refresher
&lt;/h2&gt;

&lt;p&gt;Python is a high-level, object-oriented programming language that has made tremendous strides in popularity thanks to its ease of use, even among non-programmers. It features a simple, easy-to-use syntax, and strong modular support.&lt;/p&gt;

&lt;h2&gt;
  
  
  What is Web Development
&lt;/h2&gt;

&lt;p&gt;Web development is the catch-all term for conceptualizing, creating, deploying, and operating web applications and application programming interfaces (API) for the internet. It usually involves the front end, which entails everything that interacts with the user, and the back end, which requires business logic and database interaction. &lt;br&gt;
It also includes full stack development, which means developing all parts of the application, from the front to the back.&lt;br&gt;
So, if you’re trying to create a website or a web application, you’re engaging in web development. Since the demand for websites and apps is more significant than ever, it’s a much-needed skill and occupation.&lt;/p&gt;

&lt;h2&gt;
  
  
  Python Web Development
&lt;/h2&gt;

&lt;p&gt;If you want to master Python web development, you should follow these steps. You don’t have to be a programmer to tackle this but there are specific skills and concepts that you should become familiar with before taking on development tasks.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Learn CSS and HTML&lt;/strong&gt;. These two languages are the building blocks used to create websites. Learn them and use that knowledge to learn how to structure responsive static pages. &lt;br&gt;
&lt;em&gt;For extra credit, familiarize yourself with a CSS framework like Bootstrap or Materialize.&lt;/em&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Learn Basic JavaScript&lt;/strong&gt;. Next, learn vanilla JavaScript. “Vanilla” means using plain, ordinary JavaScript without additional libraries such as jQuery.&lt;br&gt;
&lt;em&gt;Familiarize yourself with concepts like control statements, data types, general conventions, variables, string manipulation, arithmetic and operators, and loops.&lt;/em&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Learn About DOM and jQuery&lt;/strong&gt;. Once you get the JavaScript fundamentals down, you should learn about the JavaScript library jQuery and manipulating the Document Object Model (DOM).&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Learn Python.&lt;/strong&gt; Yes, here is where you finally learn Python. Cover the basics and fundamentals, and you will be ready to tackle the application’s back end.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Learn Database and Django&lt;/strong&gt;. Familiarize yourself with databases, the CRUD functions (create, read, update, and delete), and how to make queries. Django helps you set up the backend environment and develop business logic.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Ending Thoughts
&lt;/h2&gt;

&lt;p&gt;Web development using Python has been very popular for years – and for all the right reasons. Not only is it a perfect language for beginners but it can also serve you as stepping stone for learning more complicated languages. Python web development is something every developer should give a try. Learning it is a piece of cake while the benefits of learning Python are amazing, especially when it comes to working on a short deadline and/or on a budget.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Python 101: The Ultimate Python Tutorial for Beginners</title>
      <dc:creator>It's pronounced W3SHY</dc:creator>
      <pubDate>Sun, 24 Apr 2022 11:40:42 +0000</pubDate>
      <link>https://dev.to/itsweshy/python-101-the-ultimate-python-tutorial-for-beginners-1bci</link>
      <guid>https://dev.to/itsweshy/python-101-the-ultimate-python-tutorial-for-beginners-1bci</guid>
      <description>&lt;p&gt;Is this the first time you are thinking about coding and becoming a programmer? Here I will help you with the simple python basics to get you started. &lt;/p&gt;

&lt;h2&gt;
  
  
  Introduction to Python
&lt;/h2&gt;

&lt;p&gt;Python was created in the late 1980's by Guido Van Rossum. It is maintained and supported by the Python Software Foundation. &lt;br&gt;
Python is a general-purpose programming language. It is used in various fields such as mathematics, agriculture, electronics, and mechanics.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;It is a &lt;strong&gt;Strongly Typed&lt;/strong&gt; language- meaning that every object in Python has a definite type associated with it&lt;/li&gt;
&lt;li&gt;It is also &lt;strong&gt;Dynamically Typed&lt;/strong&gt;- meaning that no type checking is done prior to running Python code.&lt;/li&gt;
&lt;li&gt;Python is an &lt;strong&gt;Interpreted Language&lt;/strong&gt;. This means that code compilation and execution is done at the same time.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;
  
  
  Where can we use Python?
&lt;/h2&gt;

&lt;p&gt;The Python language is used in many different fields.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Web Development&lt;/strong&gt; - Python is used to create really dynamic websites using frameworks like &lt;strong&gt;Flask&lt;/strong&gt; and &lt;strong&gt;Django&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Scientific Computing&lt;/strong&gt; - It has several libraries dedicated to it for scientific computing like &lt;strong&gt;numpy&lt;/strong&gt;, and &lt;strong&gt;earthpy&lt;/strong&gt; for earth sciences.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Game Development&lt;/strong&gt; - Python has a gaming library called &lt;strong&gt;pygame&lt;/strong&gt; for creating games that use keyboard and mouse interactions.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Desktop Applications&lt;/strong&gt; - Python comes with &lt;strong&gt;tkinter&lt;/strong&gt; a graphical user interface library that allows us to create user interfaces for our applications.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Several companies use Python in their day-to-day running's. Here is a list of just a few:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Google (YouTube)&lt;/li&gt;
&lt;li&gt;NASA&lt;/li&gt;
&lt;li&gt;IBM&lt;/li&gt;
&lt;li&gt;Mozilla&lt;/li&gt;
&lt;li&gt;Quora&lt;/li&gt;
&lt;li&gt;Instagram&lt;/li&gt;
&lt;li&gt;Reddit&lt;/li&gt;
&lt;li&gt;Disney&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;
  
  
  Installation
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Go to the Python's &lt;a href="https://www.python.org/downloads/"&gt;Downloads Page&lt;/a&gt; and download the latest version.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;NOTE&lt;/strong&gt;: &lt;em&gt;Always ensure that python has been correctly downloaded and is able to run on your PC. To check if it is properly installed on your machine.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Windows&lt;/strong&gt;&lt;br&gt;
On the Start menu or search bar find Python and click Enter then try running it or try using the following command line one the Terminal:&lt;br&gt;
&lt;code&gt;C:\Users\user&amp;gt;python --version&lt;br&gt;
&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Mac OS/ Linux&lt;/strong&gt;&lt;br&gt;
To verify if python was successfully installed, open your Terminal and run the command line.&lt;br&gt;
&lt;code&gt;python3 --version&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;This is what you see,&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;C:\Users\user&amp;gt;python --version
Python 3.9.7

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

&lt;/div&gt;



&lt;h2&gt;
  
  
  Python Basics
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Strings&lt;/strong&gt; - In Python, we can create strings with either single quotes (') or double quotes (") and Python treats them as the same thing.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt;&amp;gt;&amp;gt; 'This is a string'
This is a string
&amp;gt;&amp;gt;&amp;gt; "This is also a string"
This is also a string

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

&lt;/div&gt;



&lt;p&gt;There are also some string methods that allow us to perform actions on the string.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt;&amp;gt;&amp;gt; 'This is a string'.upper()
THIS IS A STRING
&amp;gt;&amp;gt;&amp;gt; 'this is a string'.capitalize()
This is a string

&amp;gt;&amp;gt;&amp;gt; 'this is a string'.strip()
This is a string
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The &lt;code&gt;upper()&lt;/code&gt; method is used to transform strings to uppercase. &lt;br&gt;
The &lt;code&gt;capitalize()&lt;/code&gt; method transforms the first letter of the string to a capital letter. &lt;br&gt;
The &lt;code&gt;strip()&lt;/code&gt; method removes any trailing spaces in a string.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Numbers&lt;/strong&gt; - We can also do some mathematical computations in Python.
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt;&amp;gt;&amp;gt; 3 + 2 # addition
5
&amp;gt;&amp;gt;&amp;gt; 31 - 10 # subtraction
21
&amp;gt;&amp;gt;&amp;gt; 3 * 4 # multiplication
12
&amp;gt;&amp;gt;&amp;gt; 12 / 3 # division
4.0
&amp;gt;&amp;gt;&amp;gt; 12 % 5 # modulus
2
&amp;gt;&amp;gt;&amp;gt; 2 ** 4 # Exponential
16
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;Here, we see a new character #. This hash or pound sign is Python's way to create comments. Anything after the # is ignored by the Python interpreter.&lt;br&gt;
Notice that when we use the / operator, Python doesn't return a whole number, but a number with a decimal point. It is referred to as a float division. Decimal point numbers in Python are called floats.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt;&amp;gt;&amp;gt; 30 / 5
6.0
&amp;gt;&amp;gt;&amp;gt; 45 / 9
5.0
&amp;gt;&amp;gt;&amp;gt; 25 // 5
5
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here we see some more examples using the / to get floats. We also see another division operator in Python: //. This divides the numbers, then rounds down the result and returns a whole number, and is called the integer division.&lt;/p&gt;

&lt;h2&gt;
  
  
  Data Types
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;int&lt;/code&gt;: whole numbered integers&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;float&lt;/code&gt;: integers with decimal points.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;None&lt;/code&gt;: represents a null or non-existent value.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;bool&lt;/code&gt;: represent boolean statements and have only 2 possible values: &lt;code&gt;True&lt;/code&gt; or &lt;code&gt;False&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Collections
&lt;/h2&gt;

&lt;p&gt;As the name suggests, collections store multiple values.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--sayK1qDI--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/jdxyy4t8v73b6c16r8t4.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--sayK1qDI--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/jdxyy4t8v73b6c16r8t4.jpg" alt="Collections description" width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;code&gt;str&lt;/code&gt; - This data type is used to represent string values&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;byte&lt;/code&gt; - This data type is used to represent byte strings.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;list&lt;/code&gt; - This is a collection used to group related data in an ordered way. &lt;a href="https://www.pythontutorial.net/python-basics/python-list/"&gt;Learn More&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;dict&lt;/code&gt; - These allow us to create dictionaries which is data that is stored in key-value pairs.  &lt;a href="https://www.pythontutorial.net/python-basics/python-dictionary/"&gt;Learn more&lt;/a&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Variables
&lt;/h2&gt;

&lt;p&gt;Variables are named references to objects.&lt;br&gt;
Here is an example of how we create a variable in Python in the Python shell:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt;&amp;gt;&amp;gt; x = 4
&amp;gt;&amp;gt;&amp;gt; x
4
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Python variables can store values from any data type. Python is dynamic in nature hence we do not have to specify what type of data we are storing.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt;&amp;gt;&amp;gt; x = 12
&amp;gt;&amp;gt;&amp;gt; x
12
&amp;gt;&amp;gt;&amp;gt; x = "Hello"
&amp;gt;&amp;gt;&amp;gt; x
Hello
&amp;gt;&amp;gt;&amp;gt; pie = 3.1423
&amp;gt;&amp;gt;&amp;gt; pie
3.1423
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  &lt;code&gt;input()&lt;/code&gt; function
&lt;/h2&gt;

&lt;p&gt;The &lt;code&gt;input()&lt;/code&gt; function is called inside our Python application and prompts the user to pass in an input, which is stored as a string&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;input_demo.py&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;print("What is your name?")
name = input()

print("How old are you?")
age = int(input())

print(name)
print(age)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We run the file:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ python3 input_demo.py
"What is your name?"
James
"How old are you?"
19

James
19
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Control Flow
&lt;/h2&gt;

&lt;p&gt;Up to now our applications haven't been that interesting. Let us add some logic to our applications.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;code&gt;if&lt;/code&gt; statements&lt;/strong&gt;&lt;br&gt;
An &lt;code&gt;if&lt;/code&gt; statement runs only when the condition passed to it evaluates to true&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;input_demo.py&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;height = 74 # The unit is inches
if height &amp;gt; 70 :
    print("You are really tall")
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Run the file in the console:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ python3.6 input_demo.py
You are really tall
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Python uses &lt;strong&gt;indents&lt;/strong&gt;. Indents are just four spaces we give to our application to define blocks of code. If we don't indent blocks of our code, we get an &lt;strong&gt;IndentationError&lt;/strong&gt; and our program won't run.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Comparison Operators&lt;/strong&gt;&lt;br&gt;
Let us look at some of the comparison operators we will be using in Python&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;&amp;gt;&lt;/code&gt; Greater than&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;&amp;lt;&lt;/code&gt; Less than&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;==&lt;/code&gt; Equal to&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;!=&lt;/code&gt; not equal to&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;&amp;gt;=&lt;/code&gt; Greater than or equal to&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;&amp;lt;=&lt;/code&gt; Less than or Equal to&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;and&lt;/code&gt; checks if both conditions evaluate to true&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;or&lt;/code&gt; checks if at least one condition is true&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;not&lt;/code&gt; returns the opposite of the condition given&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;code&gt;else&lt;/code&gt;&lt;br&gt;
The &lt;code&gt;else&lt;/code&gt; statement comes right at the end of the &lt;code&gt;if&lt;/code&gt; statement. It is run only when the &lt;code&gt;if&lt;/code&gt; statement evaluates to &lt;code&gt;False&lt;/code&gt;. Let's add an &lt;code&gt;else&lt;/code&gt; statement to our example program:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;input_example.py&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;height = 54 # inches
if height &amp;gt; 70 :
    print("You are really tall")
else:
    print("You are really short")
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now when we run the file, we get a different message:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ python3.6 input_demo.py
You are really short

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

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;elif&lt;/code&gt;&lt;br&gt;
What if we have more than one condition to check for? We can use &lt;code&gt;elif&lt;/code&gt;, which will allow us to check for multiple conditions. Looking at our example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;height = 68 # inches
if height &amp;gt; 70 :
    print("You are really tall")
elif height &amp;gt; 60:
    print("You are of average height")

else:
    print("You are really short")
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now let's run it:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ python3.6 input_demo.py
You are of average height
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Since the height is greater than 60, the &lt;code&gt;elif&lt;/code&gt; statement will be executed first and Python never reaches the &lt;code&gt;else&lt;/code&gt; statement.&lt;/p&gt;

&lt;h2&gt;
  
  
  Looping
&lt;/h2&gt;

&lt;p&gt;A loop is a way to execute some piece of code over and over again. There are 2 kinds of loops in Python;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;code&gt;for&lt;/code&gt; loop&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;while&lt;/code&gt; loop&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Learn more on &lt;a href="https://www.pythontutorial.net/python-basics/python-for-range/"&gt;Loops&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Functions
&lt;/h2&gt;

&lt;p&gt;We have already used functions to perform several tasks but let's learn how to create our own functions in python.&lt;/p&gt;

&lt;p&gt;Functions are blocks of code that begin with the def keyword&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;def fun_a():
    print("I have been called")

fun_a()

"I have been called"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This example we have created a function with no arguments and in the function we have a print statement that outputs a string&lt;/p&gt;

&lt;p&gt;Passing Arguments&lt;br&gt;
In python you can also pass arguments to functions&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;def fun_a (a,b):
    print(a+b)

fun_a(1,4)
5

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

&lt;/div&gt;



&lt;p&gt;Learn more on &lt;a href="https://www.pythontutorial.net/python-basics/python-functions/"&gt;Functions&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Exceptions and Error Handling&lt;/strong&gt;&lt;br&gt;
There are some error that are caused by programmers themselves. These errors should not be handled but fixed.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;code&gt;IndentationError&lt;/code&gt; - when you fail to separate code blocks properly.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;NameError&lt;/code&gt; - when you call an undefined variable function or method.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;TypeError&lt;/code&gt; - when you try and perform operations on unrelated types.&lt;/li&gt;
&lt;/ol&gt;

</description>
    </item>
  </channel>
</rss>
