DEV Community

Silas Ochieng
Silas Ochieng

Posted on • Edited on

Day2: Setting Up and Testing My Django Inventory App

Today was a productive day on my Django project — I successfully set up the inventory app, added models, and ran initial tests to confirm everything works as expected. Here’s a quick rundown of what I did, lessons learned, and what’s next.

Project Overview

I'm currently building a store management system using Django. One of the core components is the Inventory app, responsible for managing products, stock levels, categories, and suppliers.

What I Did Today

Set Up the Inventory App
I created the app with:

python manage.py startapp inventory
Enter fullscreen mode Exit fullscreen mode

Then I added 'inventory' to INSTALLED_APPS in settings.py.

Defined the Models
I built out the initial models for:

  • Product

  • Category

  • Supplier

  • Stock


class Product(models.Model):
    name = models.CharField(max_length=100)
    category = models.ForeignKey(Category, on_delete=models.CASCADE)
    quantity = models.PositiveIntegerField()
    supplier = models.ForeignKey(Supplier, on_delete=models.SET_NULL, null=True)
    price = models.DecimalField(max_digits=10, decimal_places=2)
    created_at = models.DateTimeField(auto_now_add=True)
Enter fullscreen mode Exit fullscreen mode

Made and Applied Migrations

python manage.py makemigrations
python manage.py migrate
Enter fullscreen mode Exit fullscreen mode

The database schema was generated and applied without issues.

Tested the Models via the Admin Interface

I registered the models in admin.py, created some test data via the Django admin, and confirmed that:

Products are linked correctly to their categories and suppliers.

Data is saved and retrieved as expected.

admin.site.register(Product)
admin.site.register(Category)
admin.site.register(Supplier)

Enter fullscreen mode Exit fullscreen mode

admin interface

admin

What I Learned

  • How to structure interrelated models with ForeignKey and on_delete.

  • The importance of meaningful model field names and types.

  • Django admin is a powerful way to quickly test your models without writing views or templates yet.
    What’s Next

  • Set up views and templates to list and manage products from the frontend.

  • Add CRUD functionality for inventory items.

  • Implement stock notifications for low inventory levels.

Final Thoughts
Setting up your models is foundational to any Django project. Today reminded me that once you get this right, everything else becomes easier — from views to APIs. I'm excited to keep building on this and share more as I go.

If you're working on something similar, I’d love to connect and hear what challenges or tips you’ve picked up!

👋 Let's Connect
Follow me here on https://dev.to/silasochieng— more dev logs coming soon!

Top comments (0)