DEV Community

Rouwel Ngacha
Rouwel Ngacha

Posted on • Edited on

Getting Started with Django: From Zero to 70% in Record Time : Step 1

For this post, I would like to help anyone who is not familiar with Django to get somewhat of an understanding on how to use it to get from 0 to maybe 70% completion of a project in record time.

So first you have to understand that there are multiple Python frameworks out there(Flask, FastAPI). The choice of which one to use is always up to you and the constraints on the project your working on.

With that being said let's dive in.

Step 1: Ensure you have to have Django installed
To install Django we will be using pip(a python package installer) which means you should have Python downloaded and configured in your path.

Creating a folder and checking if python is installed
(Creating a folder and checking if python is installed)

Something else I would like to encourage is the use of a Python virtual environment. You may not be familiar with this concept but trust me - there is not better time to learn how to use it.

The idea behind it is that, inside that environment you can install all you python packages while inside the environment and as long as you initialize your environment all your project dependencies will be inside. Sounds good?
Creating a python environment
(Creating a python environment)

Now that you are in your environment, use pip to install Django.

Step 2: Creating a project
So to start a project the command is django-admin startproject projectname

Once you ran this command, it will create a folder where there are a few preconfigured python code files inside.
Pre comfigured project files
(Pre-configured project files)

Now that we have created a project, we will need to initialize a Django app while inside that folder. The command is python manage.py startapp

Now once you open your IDE, you will realized that you have a few code files inside your NewProject folder.

Step 3: Running the server
The final part of this post focuses on how to run the server. In later entries we will dive deeper and create a small-scale working example using all of Django's extensive features, but that is for later.

To run the server use py manage.py runserver.
terminal image

So when you go to localhost at port 8000 you will find

And there you have it! You have successfully installed Django, created a project, initialized an app, and got your development server running. While this may seem like a small set of steps, this is the foundation that every Django project is built on.

Top comments (2)

Collapse
 
francis_cidney_awuor profile image
Francis Awuor

Does this work on linux?

Collapse
 
rrouwelng profile image
Rouwel Ngacha

I have just realized that this process works on Windows only , I am currently writing another one on the Windows Sub System For Linux on the same. Stay tuned.