Add SKU field to Product model (issue #67)
This commit is contained in:
+2
-2
@@ -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
|
||||
|
||||
@@ -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),
|
||||
),
|
||||
]
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user