diff --git a/core/__pycache__/admin.cpython-311.pyc b/core/__pycache__/admin.cpython-311.pyc index cd6f855..fc33bde 100644 Binary files a/core/__pycache__/admin.cpython-311.pyc and b/core/__pycache__/admin.cpython-311.pyc differ diff --git a/core/__pycache__/models.cpython-311.pyc b/core/__pycache__/models.cpython-311.pyc index 9aa598b..a7b496d 100644 Binary files a/core/__pycache__/models.cpython-311.pyc and b/core/__pycache__/models.cpython-311.pyc differ diff --git a/core/__pycache__/urls.cpython-311.pyc b/core/__pycache__/urls.cpython-311.pyc index 1f807fa..b4c1f9d 100644 Binary files a/core/__pycache__/urls.cpython-311.pyc and b/core/__pycache__/urls.cpython-311.pyc differ diff --git a/core/__pycache__/views.cpython-311.pyc b/core/__pycache__/views.cpython-311.pyc index 6867ddf..b689a39 100644 Binary files a/core/__pycache__/views.cpython-311.pyc and b/core/__pycache__/views.cpython-311.pyc differ diff --git a/core/admin.py b/core/admin.py index 8c38f3f..e4a053d 100644 --- a/core/admin.py +++ b/core/admin.py @@ -1,3 +1,8 @@ from django.contrib import admin +from .models import Product -# Register your models here. +@admin.register(Product) +class ProductAdmin(admin.ModelAdmin): + list_display = ('name', 'category', 'sku', 'price', 'stock', 'minimum_stock_level') + search_fields = ('name', 'sku') + list_filter = ('category',) \ No newline at end of file diff --git a/core/migrations/0001_initial.py b/core/migrations/0001_initial.py new file mode 100644 index 0000000..52bc3cd --- /dev/null +++ b/core/migrations/0001_initial.py @@ -0,0 +1,26 @@ +# Generated by Django 5.2.7 on 2026-01-18 11:36 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + initial = True + + dependencies = [ + ] + + operations = [ + migrations.CreateModel( + name='Product', + fields=[ + ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('name', models.CharField(max_length=200)), + ('category', models.CharField(blank=True, max_length=100, null=True)), + ('sku', models.CharField(max_length=100, unique=True)), + ('price', models.DecimalField(decimal_places=2, max_digits=10)), + ('stock', models.PositiveIntegerField()), + ('minimum_stock_level', models.PositiveIntegerField(default=10)), + ], + ), + ] diff --git a/core/migrations/__pycache__/0001_initial.cpython-311.pyc b/core/migrations/__pycache__/0001_initial.cpython-311.pyc new file mode 100644 index 0000000..6864246 Binary files /dev/null and b/core/migrations/__pycache__/0001_initial.cpython-311.pyc differ diff --git a/core/models.py b/core/models.py index 71a8362..661aceb 100644 --- a/core/models.py +++ b/core/models.py @@ -1,3 +1,16 @@ from django.db import models +from django.urls import reverse -# Create your models here. +class Product(models.Model): + name = models.CharField(max_length=200) + category = models.CharField(max_length=100, blank=True, null=True) + sku = models.CharField(max_length=100, unique=True) + price = models.DecimalField(max_digits=10, decimal_places=2) + stock = models.PositiveIntegerField() + minimum_stock_level = models.PositiveIntegerField(default=10) + + def __str__(self): + return self.name + + def is_below_minimum_stock(self): + return self.stock < self.minimum_stock_level diff --git a/core/templates/base.html b/core/templates/base.html index 1e7e5fb..2eb01fe 100644 --- a/core/templates/base.html +++ b/core/templates/base.html @@ -3,7 +3,8 @@
-