DEV Community

Silas Ochieng
Silas Ochieng

Posted on • Edited on

Day 1 of 20 Days of Django: Let’s Build a Store Manager App!

👋 Welcome Back!
Let’s get started with building a Django project that manages products and customer orders.

We’ll start by creating a Django project called store_manager, then add two apps — one for managing inventory and another for handling orders.

Step 1: Create Your Project Folder and Environment

To get started, I used Visual Studio Code as my IDE and followed these steps to structure my Django project cleanly with two separate apps: inventory and orders.

  • You can create your project folder using either the terminal or the VS Code file explorer.

While at the terminal run and it will take you to the folder

A table showing the commands to run at the terminal to create a project folder
or use the file explorer if you prefer and click on a open folder and right-click in the explorer sidebar and select "New Folder".

Name the folder store_manager.
Creation from filw explorere

Open that folder in VS Code
Once inside your project folder, open the terminal in VS Code by going to Terminal → New Terminal.

Step 2: Set up a virtual environment

run the following in your project root directory in the terminal

python -m venv venv
Enter fullscreen mode Exit fullscreen mode

Step 3: Activate the virtual environment

while at windows powershell use

../venv/Scripts/Activate
`

Activating the virtuall environment

Step 4: Install Django

Now install Django in your virtual environment:


pip install django

An image showing installation of django

Step 5:Create the Django Project and Apps after successful installation of django in the virtual enviroment

We now initialize our Django project and create two apps inside it:

Create the Django project


django-admin startproject store_manager

Create two apps: inventory and orders


python manage.py startapp inventory
python manage.py startapp orders

Now our folder structure looks like this

Django project settings

Register the two apps in settings

Open

store_manager/settings.py

and add both apps to the INSTALLED_APPS list:

installed apps

Step 6 Set Up Templates for Each App

Inside each app, I created its own templates folder:
For the inventory app:

mkdir -p inventory/templates/inventory

For the orders app:

mkdir -p orders/templates/orders

Step 7 Create App URL Configurations

Each app gets its own urls.py file.

inventory/urls.py
orders/urls.py

Step 8 Link App URLs in the Main Project

That is at

store_manager/urls.py:

Linking the urls
Add static files in each app directory

inventory
Do so for orders app too
Then add media files upload to the project root directory

media uploads

Step 9 Add basic views in inventory and orders app

inventory view.py
Inventory app view
orders view.py
orders app view

Step 10 Run Migrations and Start Server

Still at the terminals run the following to test


python manage.py migrate
python manage.py runserver

Just to conclude my django setup for the store_manager app ran successfully.

setup

Conclusion

This is just but the beginning of my 20days of django keep tune by diving with me into day two of my journey at
https://dev.to/silasochieng and follow in my github account at https://github.com/Silas-ochieng

Top comments (0)