All checks were successful
Deploy Beta (NATIVE) / deploy (push) Successful in 18s
34 lines
1.3 KiB
Python
34 lines
1.3 KiB
Python
from django.db import models
|
|
from django.contrib.auth.models import User
|
|
|
|
class Category(models.Model):
|
|
name = models.CharField(max_length=100)
|
|
slug = models.SlugField(max_length=100, unique=True, blank=True)
|
|
is_active = models.BooleanField(default=True)
|
|
sort_order = models.IntegerField(default=0)
|
|
|
|
class Meta:
|
|
verbose_name_plural = "Categories"
|
|
ordering = ['sort_order', 'name']
|
|
|
|
def __str__(self):
|
|
return self.name
|
|
|
|
class Product(models.Model):
|
|
# Align to seller_central_backend api_product schema
|
|
supplier = models.ForeignKey(User, on_delete=models.CASCADE, related_name='products', db_constraint=False)
|
|
title = models.CharField(max_length=255)
|
|
category = models.CharField(max_length=100) # CharField matching seller central
|
|
price = models.DecimalField(max_digits=10, decimal_places=2)
|
|
stock = models.IntegerField(default=0)
|
|
sku = models.CharField(max_length=100, unique=True)
|
|
image = models.TextField(blank=True, null=True) # Textfield for base64 / URL
|
|
status = models.CharField(max_length=50, default='pending')
|
|
is_active = models.BooleanField(default=True)
|
|
|
|
class Meta:
|
|
db_table = 'api_product'
|
|
managed = False # Managed by seller central backend migrations
|
|
|
|
def __str__(self):
|
|
return self.title
|