<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Vishwa - Senior AI Engineer]]></title><description><![CDATA[Hey there, this is Vishwa]]></description><link>https://blog.vishwa.be</link><generator>RSS for Node</generator><lastBuildDate>Fri, 11 Sep 2026 00:47:43 GMT</lastBuildDate><atom:link href="https://blog.vishwa.be/rss.xml" rel="self" type="application/rss+xml"/><language><![CDATA[en]]></language><ttl>60</ttl><item><title><![CDATA[Django: Getting Started]]></title><description><![CDATA[In this series, we are going to create a random motivational quotes generator using Django. This is a beginner-friendly series, so you don't have to have any prior knowledge of Django. Oh, by the way, it's pronounced JANG-OH, you're welcome. ;)

Disc...]]></description><link>https://blog.vishwa.be/django-getting-started</link><guid isPermaLink="true">https://blog.vishwa.be/django-getting-started</guid><category><![CDATA[Python 3]]></category><category><![CDATA[Django]]></category><category><![CDATA[python beginner]]></category><category><![CDATA[Web Development]]></category><dc:creator><![CDATA[Vishwa]]></dc:creator><pubDate>Sun, 16 May 2021 16:07:33 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1621168647274/ejOPwIN7p.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>In this series, we are going to create a random motivational quotes generator using Django. This is a beginner-friendly series, so you don't have to have any prior knowledge of Django. Oh, by the way, it's pronounced <a target="_blank" href="https://docs.djangoproject.com/en/3.2/faq/general/#what-does-django-mean-and-how-do-you-pronounce-it">JANG-OH</a>, you're welcome. ;)</p>
<blockquote>
<p>Disclaimer: I am not a Django expert. I am learning Django by doing &amp; sharing articles like this. The code I write here might not be great, but I welcome your suggestions/feedback.</p>
</blockquote>
<h3 id="what-is-django">What is Django</h3>
<p>Django is a web framework written in python with batteries included. It gives us several functionalities out of the box, such as user authentication, admin panel, etc.</p>
<h3 id="setup">Setup</h3>
<p>Once you have python3 and pip installed, fire up the Terminal (on Mac/Linux) or command prompt (on windows) in a fresh new directory, say, quotesgen and let's get started.</p>
<ul>
<li><p>virtualenv is a very helpful python module to build isolated environments. Let's begin by creating our virtualenv called venv for this project.</p>
<pre><code><span class="hljs-attribute">python3</span> -m venv venv
</code></pre></li>
<li><p>Let's activate it now.</p>
<pre><code><span class="hljs-keyword">source</span> venv/bin/activate
</code></pre></li>
<li><p>The terminal/command prompt should look something like this once the virtualenv is activated.
<img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1621111927126/VeLV1x2yC.png" alt="image.png" /></p>
</li>
<li><p>Install Django</p>
<pre><code><span class="hljs-attribute">pip</span> install -U django
</code></pre></li>
</ul>
<h3 id="my-first-django-app">My first Django app</h3>
<p>Now that we have everything set up, we can start implementing our first ever Django application.</p>
<p>Let's start by creating a new Django project using <code>django-admin</code>.  <a target="_blank" href="https://docs.djangoproject.com/en/3.2/ref/django-admin/">django-admin</a>  is a command-line utility that comes packaged with Django, it has several utilities to simplify the development; we'll learn about each of them as we progress into the course.</p>
<p>Just run the following command to create a django project called <code>quotesgen</code>.</p>
<pre><code>django-<span class="hljs-keyword">admin</span> startproject quotesgen .
</code></pre><p>This creates a <code>manage.py</code> file and a directory <code>quotesgen</code> with a bunch of files inside it. Overall, the directory structure should look something like this:</p>
<pre><code><span class="hljs-selector-tag">quotesgen</span>
├── <span class="hljs-selector-tag">manage</span><span class="hljs-selector-class">.py</span>
└── <span class="hljs-selector-tag">quotesgen</span>
    ├── __<span class="hljs-selector-tag">init__</span><span class="hljs-selector-class">.py</span>
    ├── <span class="hljs-selector-tag">asgi</span><span class="hljs-selector-class">.py</span>
    ├── <span class="hljs-selector-tag">settings</span><span class="hljs-selector-class">.py</span>
    ├── <span class="hljs-selector-tag">urls</span><span class="hljs-selector-class">.py</span>
    └── <span class="hljs-selector-tag">wsgi</span><span class="hljs-selector-class">.py</span>
</code></pre><p>Now let's go through each file generated.</p>
<ul>
<li><code>manage.py</code>: this file allows us to run commands such as making migrations, running the server, etc. We'll learn more about it soon.</li>
<li><code>quotesgen/__init__.py</code>: Django generates a directory with the same name as our project name &amp; a  <a target="_blank" href="https://docs.python.org/3/tutorial/modules.html#packages">empty <code>__init__.py</code></a>  file is created in it to indicate that it's a python package.
<code>quotesgen/settings.py</code>: <code>settings.py</code> holds the entire project's configuration, including DB credentials, security keys, etc.</li>
<li><code>quotesgen/urls.py</code>: <code>urls.py</code> file contains URL routes &amp; mapping to appropriate packages.</li>
<li><code>quotesgen/wsgi.py</code> &amp; <code>quotesgen/asgi.py</code>: Both wsgi.py &amp; asgi.py act as an interface for our web server. A default configuration is added to help us get started quickly.</li>
</ul>
<h3 id="testing-it-out">Testing it out</h3>
<p>Unlike other frameworks, we don't need to write any code to run the Django application. Django comes with a basic webpage built-in; we, simply need to run a command to view it.</p>
<p>To start the server, we need run:</p>
<pre><code><span class="hljs-selector-tag">python</span> <span class="hljs-selector-tag">manage</span><span class="hljs-selector-class">.py</span> <span class="hljs-selector-tag">runserver</span>
</code></pre><p>This will start the webserver &amp; we should see a message saying <code>Starting development server at http://127.0.0.1:8000/</code></p>
<p>Now, go ahead &amp; open the URL  <a target="_blank" href="http://127.0.0.1:8000/">http://127.0.0.1:8000</a> on your browser, and we should see a standard django template like this</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1621168429575/0HxDPmEKh.png" alt="image.png" /></p>
<p>Congratulations on setting up your first django app. 🎉 That's it for today, and in the second part of this series, we'll learn to create a new app, setting up custom URL routes, writing &amp; reading from the database.</p>
<p>Thanks for reading. .</p>
<p>PS: This is my first time writing a blog, any feedback/suggestions towards improvement is <em>really</em> appreciated.</p>
]]></content:encoded></item></channel></rss>