diff --git a/tienda/admin.py b/tienda/admin.py index ab03a94..17ada62 100644 --- a/tienda/admin.py +++ b/tienda/admin.py @@ -10,8 +10,8 @@ admin.site.register(VerificationCode) @admin.register(Product) class ProductAdmin(admin.ModelAdmin): - list_display = ('id', 'name', 'price', 'stock', 'category', 'creator') - search_fields = ('name', 'creator__username', 'creator__email') + list_display = ('id', 'sku', 'name', 'price', 'stock', 'category', 'creator') + search_fields = ('name', 'sku', 'creator__username', 'creator__email') list_filter = ('category',) class CartItemInline(admin.TabularInline): model = CartItem diff --git a/tienda/migrations/0007_add_product_sku.py b/tienda/migrations/0007_add_product_sku.py new file mode 100644 index 0000000..00800e1 --- /dev/null +++ b/tienda/migrations/0007_add_product_sku.py @@ -0,0 +1,18 @@ +# Generated by Django 6.0.4 on 2026-05-05 07:01 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('tienda', '0006_alter_category_name'), + ] + + operations = [ + migrations.AddField( + model_name='product', + name='sku', + field=models.CharField(blank=True, max_length=50, null=True, unique=True), + ), + ] diff --git a/tienda/models.py b/tienda/models.py index 4f0612b..595bd78 100644 --- a/tienda/models.py +++ b/tienda/models.py @@ -84,6 +84,7 @@ class Image(models.Model): class Product(models.Model): name = models.CharField(max_length=200, default="") + sku = models.CharField(max_length=50, unique=True, blank=True, null=True) description = models.TextField(default = "") briefdesc = models.TextField(default = "") price = models.FloatField(default = 0) @@ -107,6 +108,7 @@ class Product(models.Model): def to_dict(self): return { "name": self.name, + "sku": self.sku, "description": self.description, "briefdesc": self.briefdesc, "price": self.price,