add: add new field for product
This commit is contained in:
@@ -7,7 +7,7 @@ class AdminProductListSerializer(serializers.ModelSerializer):
|
|||||||
class Meta:
|
class Meta:
|
||||||
model = Product
|
model = Product
|
||||||
fields = [
|
fields = [
|
||||||
'id', 'name_uz', 'name_ru', 'image', 'category', 'price', 'description_uz', 'description_ru', 'unity'
|
'id', 'name_uz', 'name_ru', 'image', 'category', 'price', 'description_uz', 'description_ru', 'unity', 'tg_id', 'code', 'article',
|
||||||
]
|
]
|
||||||
|
|
||||||
def get_category(self, obj):
|
def get_category(self, obj):
|
||||||
@@ -21,11 +21,14 @@ class ProductSerializer(serializers.ModelSerializer):
|
|||||||
class Meta:
|
class Meta:
|
||||||
model = Product
|
model = Product
|
||||||
fields = [
|
fields = [
|
||||||
'name_uz', 'name_ru', 'image', 'category', 'price', 'description_uz', 'description_ru', 'unity'
|
'name_uz', 'name_ru', 'image', 'category', 'price', 'description_uz', 'description_ru', 'unity', 'tg_id', 'code', 'article',
|
||||||
]
|
]
|
||||||
extra_kwargs = {
|
extra_kwargs = {
|
||||||
'image': {'required':False},
|
'image': {'required':False},
|
||||||
'category': {'required':False},
|
'category': {'required':False},
|
||||||
'price': {'required':False},
|
'price': {'required':False},
|
||||||
|
'tg_id': {'required': False},
|
||||||
|
'code': {'required': False},
|
||||||
|
'article': {'required': False}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,28 @@
|
|||||||
|
# Generated by Django 5.2 on 2025-09-04 16:08
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('products', '0004_unity_name_ru_unity_name_uz'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='product',
|
||||||
|
name='code',
|
||||||
|
field=models.CharField(blank=True, max_length=200, null=True, unique=True),
|
||||||
|
),
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='product',
|
||||||
|
name='irticle',
|
||||||
|
field=models.CharField(blank=True, max_length=200, null=True, unique=True),
|
||||||
|
),
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='product',
|
||||||
|
name='tg_id',
|
||||||
|
field=models.CharField(blank=True, max_length=50, null=True),
|
||||||
|
),
|
||||||
|
]
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
# Generated by Django 5.2 on 2025-09-04 16:10
|
||||||
|
|
||||||
|
from django.db import migrations
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('products', '0005_product_code_product_irticle_product_tg_id'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.RenameField(
|
||||||
|
model_name='product',
|
||||||
|
old_name='irticle',
|
||||||
|
new_name='article',
|
||||||
|
),
|
||||||
|
]
|
||||||
@@ -22,6 +22,9 @@ class Product(BaseModel):
|
|||||||
price = models.PositiveBigIntegerField()
|
price = models.PositiveBigIntegerField()
|
||||||
description = models.TextField(null=True, blank=True)
|
description = models.TextField(null=True, blank=True)
|
||||||
unity = models.ForeignKey(Unity, on_delete=models.CASCADE, related_name='products', null=True)
|
unity = models.ForeignKey(Unity, on_delete=models.CASCADE, related_name='products', null=True)
|
||||||
|
tg_id = models.CharField(max_length=50, null=True, blank=True)
|
||||||
|
article = models.CharField(max_length=200, null=True, blank=True, unique=True)
|
||||||
|
code = models.CharField(max_length=200, unique=True, null=True, blank=True)
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return self.name
|
return self.name
|
||||||
|
|||||||
Reference in New Issue
Block a user