Let's Learn Django #1 Init

Full Stack Developer | Pythonista | Student | Programmer | Tech Enthusiast | Learner | Linux 🖤
Search for a command to run...

Full Stack Developer | Pythonista | Student | Programmer | Tech Enthusiast | Learner | Linux 🖤
No comments yet. Be the first to comment.
In this series, I will explain how you can start building awesome web apps with Django easily
After initialising a Django project, we can see several files. Don't worry, this blog will explain all of them in detail. The general file structure of Django looks like this: ├── [appname] │ ├── admin.py │ ├── apps.py │ ├── __init__.py │ ├──...
The Beginning: Building My First "Real" App Recently, I embarked on building a Splitwise-like expense-splitting app using React Native and Expo. This wasn't just another side project—it was my first proper dive into this tech stack, with React Native...

As AI continues to evolve, one of the limitations of generative AI is its tendency to hallucinate—producing inaccurate or nonsensical outputs, especially when it lacks relevant context. This is where Retrieval-Augmented Generation (RAG) comes in. RAG...

The general perception is that deploying applications on the cloud is complicated, but that is not always true. We have really easy ways to deploy stuff on the cloud as well. So I will be demonstrating how to deploy Django Webpps to Azure easily. Pr...

Linux is known for its flexibility and powerful command-line tools. To make the most out of your Linux system, here are five productivity tools that can enhance your workflow. 1) Zoxide (z) So you might be wondering what exactly is zoxide ? According...

In the last blog, we discussed how can we use Django templating to the fullest. In this blog, we will discuss how can we use databases and handle our data in Django. Introduction to Django databases I am hoping everyone knows what a database is, but ...

This is a blog series about Django from the very basics
Django is a really powerful Python-based web framework with the philosophy batteries included. It means it gives you everything you need to build a full-stack web application. Django's Tag line is The web framework for perfectionists with deadlines. It's because it allows you to create professional-grade web apps very quickly.
However, learning it may seem a bit complex, but believe me, it is not. And to help with that, I'm writing this blog series.
So let's start from the very basics, installation & initialising a project
Installing Django is pretty straightforward. You just need to use pip to install Django. However, it's always recommended to use a virtual environment for a project. So we will start by creating a virtual environment.
python -m venv venv
This will create a virtual environment in the venv folder. To use this environment, we need to activate it. Activating it is different in Windows, Linux & MacOS.
Bash Shell (Linux)
source ./venv/bin/activate
Fish Shell (Linux)
source ./venv/bin/activate.fish
CMD (Windows)
venv\Scripts\activate.bat
Powershell (Windows)
venv\Scripts\Activate.ps1
MacOS
source ./venv/bin/activate
After activating the virtual environment, we can install Django using pip.
pip install Django
Of this, we have successfully installed Django on our systems. So what are we waiting for? Let's start a project
To start a project, we will use the django-admin command. It will help us generate the boilerplate code.
django-admin startproject <projectname>
For eg.
django-admin startproject triviaquiz
This will generate a boilerplate code for you. It will include a lot of files like manage.py, settings.py, models.py, urls.py etc.
Now to organise our code, we divide our Django web app into several smaller sub-apps. To create a sub-app, we will again use the django-admin command.
django-admin startapp <app_name>
For eg.
django-admin startapp quiz
This will create a new folder with several other files like models.py, views.py, admin.py etc.
You can try exploring all these files yourself as Django provides comments in the boilerplate code for easy understanding.
However, I will also explain each of them in detail in my next blog.
To run the project, we will use the following command:
python manage.py runserver
This will start the server with your project at http://127.0.0.1:8000.
And by going to this url, you will a default Django page like this:

If you are seeing this, then congrats, you have successfully set up & started your project.
In the next blog, I will explain all the different Django files in detail. Stay Tuned
Follow my journey on Twitter: @notnotrachit