Add ShopModel and integrate with ProductModel
- Created ShopModel with fields for shop name, description, and user association. - Updated ProductModel to include a foreign key relationship with ShopModel. - Added admin interface for ShopModel with search functionality. - Created migrations for ShopModel and its integration with ProductModel.
This commit is contained in:
@@ -122,7 +122,7 @@ class ProductModel(models.Model):
|
||||
created_at = models.DateTimeField(auto_now_add=True, verbose_name='زمان ثبت محصول')
|
||||
category = models.ForeignKey(SubCategoryModel, null=True, on_delete=models.SET_NULL, related_name='products', verbose_name='دسته بندی محصول')
|
||||
related_products = models.ManyToManyField('self', blank=True, verbose_name='محصولات مرتبط')
|
||||
|
||||
shop = models.ForeignKey('account.ShopModel', on_delete=models.CASCADE, related_name='products', verbose_name='فروشگاه', blank=True, null=True)
|
||||
|
||||
|
||||
|
||||
@@ -287,7 +287,6 @@ class ProductVariant(models.Model):
|
||||
verbose_name = 'تنوع محصول'
|
||||
verbose_name_plural = 'تنوعهای محصول'
|
||||
indexes = [
|
||||
# Existing indexes
|
||||
models.Index(fields=['product', 'price', 'created_at'], name='idx_product_price_created'),
|
||||
models.Index(fields=['in_stock', 'discount'], name='idx_stock_discount'),
|
||||
models.Index(fields=['created_at'], name='idx_created'),
|
||||
|
||||
Reference in New Issue
Block a user