<?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[Django Project Setup]]></title><description><![CDATA[Django Project Setup]]></description><link>https://write.csubedi.com.np</link><image><url>https://cdn.hashnode.com/res/hashnode/image/upload/v1770273966214/9a9f592a-a5cf-4d43-9bcc-65fc6b0e43d5.jpeg</url><title>Django Project Setup</title><link>https://write.csubedi.com.np</link></image><generator>RSS for Node</generator><lastBuildDate>Mon, 01 Jun 2026 18:00:29 GMT</lastBuildDate><atom:link href="https://write.csubedi.com.np/rss.xml" rel="self" type="application/rss+xml"/><language><![CDATA[en]]></language><ttl>60</ttl><item><title><![CDATA[Django Project Setup]]></title><description><![CDATA[Django is a powerful Python web framework that helps you build secure, scalable web applications quickly. In this blog, we’ll walk through a complete Django project setup from scratch, using clear commands and best practices.
This guide is perfect if...]]></description><link>https://write.csubedi.com.np/django-project-setup</link><guid isPermaLink="true">https://write.csubedi.com.np/django-project-setup</guid><category><![CDATA[Django]]></category><category><![CDATA[Python]]></category><dc:creator><![CDATA[Chandan Subedi]]></dc:creator><pubDate>Tue, 03 Feb 2026 07:20:49 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/stock/unsplash/BI465ksrlWs/upload/f0f630eb575260f5b73c75aeeacfb023.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Django is a powerful Python web framework that helps you build secure, scalable web applications quickly. In this blog, we’ll walk through a <strong>complete Django project setup from scratch</strong>, using clear commands and best practices.</p>
<p>This guide is perfect if you’re a beginner or setting up a fresh Django project for production or learning.</p>
<h2 id="heading-prerequisites">Prerequisites</h2>
<p>Before starting, make sure you have:</p>
<ul>
<li><p>Python <strong>3.10+</strong> installed</p>
</li>
<li><p>Basic knowledge of terminal/command line</p>
</li>
<li><p><code>pip</code> (Python package manager)</p>
</li>
</ul>
<p>Check your Python version:</p>
<pre><code class="lang-powershell">python -<span class="hljs-literal">-version</span>
</code></pre>
<h2 id="heading-step-1-create-a-project-directory">Step 1: Create a Project Directory</h2>
<p>First, create and move into a new directory for your project.</p>
<pre><code class="lang-powershell">mkdir django_project
<span class="hljs-built_in">cd</span> django_project
</code></pre>
<h2 id="heading-step-2-create-a-virtual-environment-recommended">Step 2: Create a Virtual Environment (Recommended)</h2>
<p>A virtual environment keeps your project dependencies isolated.</p>
<pre><code class="lang-powershell">python <span class="hljs-literal">-m</span> venv venv
</code></pre>
<p>Activate it:</p>
<h3 id="heading-on-linux-macos">On Linux / macOS</h3>
<pre><code class="lang-powershell">source venv/bin/activate
</code></pre>
<h3 id="heading-on-windows"><strong>On Windows</strong></h3>
<pre><code class="lang-powershell">venv\Scripts\activate
</code></pre>
<p>You should now see <code>(venv)</code> in your terminal.</p>
<h2 id="heading-step-3-upgrade-pip">Step 3: Upgrade pip</h2>
<p>Always keep pip updated.</p>
<pre><code class="lang-powershell">pip install -<span class="hljs-literal">-upgrade</span> pip
</code></pre>
<h2 id="heading-step-4-install-django">Step 4: Install Django</h2>
<p>Install the latest stable version of Django.</p>
<pre><code class="lang-powershell">pip install django
</code></pre>
<p>Verify installation:</p>
<pre><code class="lang-powershell">django<span class="hljs-literal">-admin</span> -<span class="hljs-literal">-version</span>
</code></pre>
<h2 id="heading-step-5-create-a-django-project">Step 5: Create a Django Project</h2>
<p>Now create your Django project.</p>
<pre><code class="lang-powershell">django<span class="hljs-literal">-admin</span> startproject config .
</code></pre>
<p>The dot (<code>.</code>) prevents creating an extra nested folder.</p>
<p>Your structure will look like:</p>
<pre><code class="lang-powershell">django_project/
├── config/
│   ├── __init__.py
│   ├── settings.py
│   ├── urls.py
│   ├── asgi.py
│   └── wsgi.py
├── manage.py
└── venv/
</code></pre>
<h2 id="heading-step-6-run-initial-migrations">Step 6: Run Initial Migrations</h2>
<p>Django uses migrations to manage database schema.</p>
<pre><code class="lang-powershell">python manage.py mimgrate
</code></pre>
<h2 id="heading-step-7-create-a-superuser-admin">Step 7: Create a Superuser (Admin)</h2>
<p>To access Django admin panel:</p>
<pre><code class="lang-powershell">python manage.py createsuperuser
</code></pre>
<p>Enter:</p>
<ul>
<li><p>Username</p>
</li>
<li><p>Email (optional)</p>
</li>
<li><p>Password</p>
</li>
</ul>
<hr />
<h2 id="heading-step-8-run-the-development-server">Step 8: Run the Development Server</h2>
<p>Start the Django server:</p>
<pre><code class="lang-powershell">python manage.py runserver
</code></pre>
<p>Open your browser and visit:</p>
<pre><code class="lang-powershell">http://<span class="hljs-number">127.0</span>.<span class="hljs-number">0.1</span>:<span class="hljs-number">8000</span>/
</code></pre>
<p>Admin panel:</p>
<pre><code class="lang-powershell">http://<span class="hljs-number">127.0</span>.<span class="hljs-number">0.1</span>:<span class="hljs-number">8000</span>/admin/
</code></pre>
<p>Your Django project is now running!</p>
<hr />
<h2 id="heading-step-9-create-a-django-app">Step 9: Create a Django App</h2>
<p>Create an app for your features (e.g., blog, users, core).</p>
<pre><code class="lang-powershell">python manage.py startapp blog
</code></pre>
<p>Project structure now:</p>
<pre><code class="lang-powershell">blog/
├── admin.py
├── apps.py
├── models.py
├── tests.py
├── views.py
└── migrations/
</code></pre>
<hr />
<h2 id="heading-step-10-register-app-in-settings">Step 10: Register App in Settings</h2>
<p>Open <code>config/</code><a target="_blank" href="http://settings.py"><code>settings.py</code></a> and add your app:</p>
<pre><code class="lang-powershell">INSTALLED_APPS = [
    <span class="hljs-string">'django.contrib.admin'</span>,
    <span class="hljs-string">'django.contrib.auth'</span>,
    <span class="hljs-string">'django.contrib.contenttypes'</span>,
    <span class="hljs-string">'django.contrib.sessions'</span>,
    <span class="hljs-string">'django.contrib.messages'</span>,
    <span class="hljs-string">'django.contrib.staticfiles'</span>,

    <span class="hljs-string">'blog'</span>,
]
</code></pre>
<hr />
<h2 id="heading-step-11-create-models-and-migrate">Step 11: Create Models and Migrate</h2>
<p>After writing models in <a target="_blank" href="http://models.py"><code>models.py</code></a>:</p>
<pre><code class="lang-powershell">python manage.py makemigrations
python manage.py migrate
</code></pre>
<hr />
<h2 id="heading-step-12-freeze-dependencies-best-practice">Step 12: Freeze Dependencies (Best Practice)</h2>
<p>Save installed packages:</p>
<pre><code class="lang-powershell">pip freeze &gt; requirements.txt
</code></pre>
<p>Later you can install them using:</p>
<pre><code class="lang-powershell">pip install <span class="hljs-literal">-r</span> requirements.txt
</code></pre>
<hr />
<h2 id="heading-common-django-commands-cheat-sheet">Common Django Commands Cheat Sheet</h2>
<pre><code class="lang-powershell">python manage.py runserver
python manage.py startapp app_name
python manage.py makemigrations
python manage.py migrate
python manage.py createsuperuser
python manage.py shell
</code></pre>
<hr />
<h2 id="heading-conclusion">Conclusion</h2>
<p>Setting up a Django project is straightforward when you follow a structured approach. With virtual environments, clean project structure, and proper commands, you’re ready to build powerful web applications.</p>
]]></content:encoded></item></channel></rss>