<?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: Umair Mehmood</title>
    <description>The latest articles on DEV Community by Umair Mehmood (@umair313).</description>
    <link>https://dev.to/umair313</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%2F654971%2Fec166024-be5e-4edf-ac89-2fda1a421ab4.jpeg</url>
      <title>DEV Community: Umair Mehmood</title>
      <link>https://dev.to/umair313</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/umair313"/>
    <language>en</language>
    <item>
      <title>Django create your first web application 😀</title>
      <dc:creator>Umair Mehmood</dc:creator>
      <pubDate>Fri, 14 Oct 2022 18:24:39 +0000</pubDate>
      <link>https://dev.to/umair313/django-create-your-first-web-application-2p48</link>
      <guid>https://dev.to/umair313/django-create-your-first-web-application-2p48</guid>
      <description>&lt;p&gt;&lt;a href="https://www.djangoproject.com/" rel="noopener noreferrer"&gt;Django&lt;/a&gt; is a free open-source high-level web development framework written in python. Built by experienced developers, it enables rapid, secure, maintainable, and scaleable development. There are ready-made components you can use for fast development without the hassle of creating the wheel.&lt;/p&gt;

&lt;p&gt;In this article, you will learn how to install Django in a virtual environment,  how to create an application, the application structure..&lt;/p&gt;

&lt;h2&gt;
  
  
  Getting started
&lt;/h2&gt;

&lt;p&gt;Before moving on there is only one requirement which is python, you must have to create and run Django-based web applications. You can download and install python from &lt;a href="https://www.python.org/" rel="noopener noreferrer"&gt;python.org&lt;/a&gt;. &lt;/p&gt;

&lt;p&gt;Let's dive in and install Django. We will install Django in a virtual environment. A virtual environment is just a Python virtual environment that isolates the python interpreter, packages, libraries, and scripts installed into it from other virtual environments and from the system. It basically allows you to run different python applications with different versions of python interpreters and packages.&lt;/p&gt;

&lt;h3&gt;
  
  
  Creating virtual environment
&lt;/h3&gt;

&lt;p&gt;open your &lt;code&gt;(terminal/command prompt)&lt;/code&gt; and create a new directory&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;&lt;span class="nb"&gt;mkdir &lt;/span&gt;first-app
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Change working directory&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;&lt;span class="nb"&gt;cd &lt;/span&gt;first-app
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Create virtual environment with &lt;code&gt;venv&lt;/code&gt;, a python module which ships with python when you install it. you didn't need to install it by your self.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;python3 &lt;span class="nt"&gt;-m&lt;/span&gt; venv venv
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;it will create virtual environment with name &lt;code&gt;venv&lt;/code&gt;. &lt;/p&gt;

&lt;p&gt;Activate virtual environment&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;&lt;span class="nb"&gt;source &lt;/span&gt;venv/bin/activate
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You will see environment name in your terminal before prompt&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="o"&gt;(&lt;/span&gt;venv&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="err"&gt;$&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Install Django, again we use pip package manager to install tools which comes with python.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="o"&gt;(&lt;/span&gt;venv&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="nv"&gt;$ &lt;/span&gt;pip &lt;span class="nb"&gt;install &lt;/span&gt;django
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It will install django now we can create our application&lt;/p&gt;

&lt;p&gt;Creating application&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="o"&gt;(&lt;/span&gt;venv&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="nv"&gt;$ &lt;/span&gt;django-admin startproject first_app &lt;span class="nb"&gt;.&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;django-admin is the Django command line utility tool to perform administrative tasks. In the command above we are telling him to start the project with name first_app and &lt;code&gt;.&lt;/code&gt; will tell him to create the project in the current directory, otherwise it will create a new directory with the project name. &lt;/p&gt;

&lt;p&gt;The project is been created and the directory tree will look something 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;├── first_app
│   ├── asgi.py
│   ├── __init__.py
│   ├── settings.py
│   ├── urls.py
│   └── wsgi.py
├── manage.py
└── venv
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;we will start our server by running the following command.&lt;br&gt;
Make sure your virtual environment is still active!&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="o"&gt;(&lt;/span&gt;venv&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="nv"&gt;$ &lt;/span&gt;python manage.py runserver
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Output will be something 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;Watching for file changes with StatReloader
Performing system checks...

System check identified no issues (0 silenced).

You have 18 unapplied migration(s). 
Your project may not work properly until you apply the migrations for app(s): admin, auth, contenttypes, sessions.
Run 'python manage.py migrate' to apply them.

October 11, 2022 - 20:26:42
Django version 4.1.2, using settings 'first_app.settings'
Starting development server at http://127.0.0.1:8000/
Quit the server with CONTROL-C.

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

&lt;/div&gt;



&lt;p&gt;Now our server is running on localhost at port 8000, but we are seeing a warning, which is telling to apply the migration. when create project with django-admin there are migrations which comes with it and we need to apply those to run things smoothly because this is required.&lt;/p&gt;

&lt;p&gt;Quite the server with CONTROL-C as mentioned and apply migrations.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="o"&gt;(&lt;/span&gt;venv&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="nv"&gt;$ &lt;/span&gt;python manage.py migrate
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Output will be something like this&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;Operations to perform:
  Apply all migrations: admin, auth, contenttypes, sessions
Running migrations:
  Applying contenttypes.0001_initial... OK
  Applying auth.0001_initial... OK
  Applying admin.0001_initial... OK
  Applying admin.0002_logentry_remove_auto_add... OK
  Applying admin.0003_logentry_add_action_flag_choices... OK
  Applying contenttypes.0002_remove_content_type_name... OK
  Applying auth.0002_alter_permission_name_max_length... OK
  Applying auth.0003_alter_user_email_max_length... OK
  Applying auth.0004_alter_user_username_opts... OK
  Applying auth.0005_alter_user_last_login_null... OK
  Applying auth.0006_require_contenttypes_0002... OK
  Applying auth.0007_alter_validators_add_error_messages... OK
  Applying auth.0008_alter_user_username_max_length... OK
  Applying auth.0009_alter_user_last_name_max_length... OK
  Applying auth.0010_alter_group_name_max_length... OK
  Applying auth.0011_update_proxy_permissions... OK
  Applying auth.0012_alter_user_first_name_max_length... OK
  Applying sessions.0001_initial... OK
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;we have successfully run the migrations run the server again.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="o"&gt;(&lt;/span&gt;venv&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="nv"&gt;$ &lt;/span&gt;python manage.py runserver
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;Watching &lt;span class="k"&gt;for &lt;/span&gt;file changes with StatReloader
Performing system checks...

System check identified no issues &lt;span class="o"&gt;(&lt;/span&gt;0 silenced&lt;span class="o"&gt;)&lt;/span&gt;&lt;span class="nb"&gt;.&lt;/span&gt;
October 11, 2022 - 20:35:28
Django version 4.1.2, using settings &lt;span class="s1"&gt;'first_app.settings'&lt;/span&gt;
Starting development server at http://127.0.0.1:8000/
Quit the server with CONTROL-C.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This time we did not get the migrations warning and now you can visit the address &lt;code&gt;http://127.0.0.1:8000/&lt;/code&gt; in your browser and you will see the default Django server page.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fsdh1s0tnn5l2fal4wdve.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fsdh1s0tnn5l2fal4wdve.png" alt="django-web-application-server-umair-mehmood" width="800" height="406"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;lets create a admin user and open django admin panel&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="o"&gt;(&lt;/span&gt;venv&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="nv"&gt;$ &lt;/span&gt;python manage.py createsuperuser
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;you will be asked to enter &lt;code&gt;username&lt;/code&gt;, &lt;code&gt;email&lt;/code&gt;, &lt;code&gt;password&lt;/code&gt; and &lt;code&gt;confirm password&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;Username (leave blank to use 'umair'): admin
Email address: admin@app.com
Password: 
Password (again): 
The password is too similar to the username.
This password is too short. It must contain at least 8 characters.
This password is too common.
Bypass password validation and create user anyway? [y/N]: y
Superuser created successfully.

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

&lt;/div&gt;



&lt;p&gt;open &lt;code&gt;http://localhost:8000/admin/login/&lt;/code&gt; in your browser and login the credentials you created.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F74jk7infwsshbstzneh1.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F74jk7infwsshbstzneh1.png" alt="django-admin-panel-first-application-umair-mehmood" width="800" height="382"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Congratulations 🥳 you creating your first Django web application.&lt;/p&gt;

&lt;p&gt;That will be for this tutorial. stay tuned for the next one.&lt;/p&gt;

</description>
      <category>django</category>
      <category>python</category>
      <category>webdev</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>What is the difference between API and Webhook?</title>
      <dc:creator>Umair Mehmood</dc:creator>
      <pubDate>Wed, 10 Aug 2022 05:29:00 +0000</pubDate>
      <link>https://dev.to/umair313/the-difference-between-api-and-webhook-d9m</link>
      <guid>https://dev.to/umair313/the-difference-between-api-and-webhook-d9m</guid>
      <description>&lt;p&gt;Every business in the fast-moving tech world is in the race to provide faster services to their users, API and Wekhook helps them to achieve this goal. APIs and webhooks are both responsible for the communication between two applications, But they often get confused with each other.&lt;/p&gt;

&lt;p&gt;In this article we will discuss the difference between API and Webhook, but before that we need to understand what exactly is API and Webhook to understand the difference between these two.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What is API?&lt;/strong&gt;    &lt;/p&gt;

&lt;p&gt;API (Application Programming Interface) helps application to talk to each other and share some data. Its a two-way communication between application which share information. The purpose of API can be understood by word “Interface” in it. For example the Web Browser we use is the interface for us humans which talk to the server and receive, send, update the request data for us so we can read it. The most common use case of API is it allow communication between front-end and back-end which is two-way communication on the basis of request and response. API help to interface two different software so they can connect and share information effectively. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What is Webhook?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;A webhook can be considered as a lightweight version of API that driven by some event in the application instead of request to notify other application. Which is why some time also known as “Reversed API” as it is a one-way communication between applications.&lt;/p&gt;

&lt;p&gt;Webhooks is a user-defined HTTP callbacks which is used to notify other applications about activity in the application. For example if you have ever used “Stripe” an online  payment gateway, it has a webhook to notify real-time update of payments whenever the user click in pay button on the application.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The Difference between API and Webhook&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;API (Application Programming Interface ) is two-way communication between application for sharing resources between them. API can handle the collection of whole CRUD(Create, Read, Update, Delete) operations between applications.&lt;/p&gt;

&lt;p&gt;Webhooks are event driven lightweight API’s which is one-way communication between application just for sending data and notify other applications. it can be used where we need real-time updates.&lt;/p&gt;




&lt;p&gt;Thanks for Reading 🙂&lt;/p&gt;

</description>
      <category>api</category>
      <category>webhook</category>
    </item>
  </channel>
</rss>
