indexes of product
This commit is contained in:
@@ -17,6 +17,9 @@ class MainCategoryModel(models.Model):
|
||||
class Meta:
|
||||
verbose_name = "دستهبندی اصلی"
|
||||
verbose_name_plural = "دستهبندیهااصلی"
|
||||
indexes = [
|
||||
models.Index(fields=['slug'], name='main_category_slug_idx'),
|
||||
]
|
||||
|
||||
def __str__(self):
|
||||
return self.name
|
||||
@@ -39,6 +42,10 @@ class SubCategoryModel(models.Model):
|
||||
class Meta:
|
||||
verbose_name = "زیر دستهبندی"
|
||||
verbose_name_plural = "زیر دستهبندیها"
|
||||
indexes = [
|
||||
models.Index(fields=['slug'], name='sub_category_slug_idx'),
|
||||
models.Index(fields=['parent'], name='sub_category_parent_idx'),
|
||||
]
|
||||
|
||||
def __str__(self):
|
||||
return self.name
|
||||
@@ -84,6 +91,9 @@ class DollorModel(models.Model):
|
||||
class Meta:
|
||||
verbose_name = 'مدل دلار'
|
||||
verbose_name_plural = 'مدل دلار'
|
||||
indexes = [
|
||||
models.Index(fields=['unique_filed'], name='dollor_unique_field_idx'),
|
||||
]
|
||||
|
||||
|
||||
class InPackItems(models.Model):
|
||||
@@ -127,6 +137,15 @@ class ProductModel(models.Model):
|
||||
class Meta:
|
||||
verbose_name = 'محصول'
|
||||
verbose_name_plural = 'محصولات'
|
||||
indexes = [
|
||||
models.Index(fields=['slug'], name='product_slug_idx'),
|
||||
models.Index(fields=['category'], name='product_category_idx'),
|
||||
models.Index(fields=['name'], name='product_name_idx'),
|
||||
models.Index(fields=['created_at'], name='product_created_at_idx'),
|
||||
models.Index(fields=['show'], name='product_show_idx'),
|
||||
models.Index(fields=['category', 'created_at'], name='product_category_created_idx'),
|
||||
models.Index(fields=['category', 'name'], name='product_category_name_idx'),
|
||||
]
|
||||
|
||||
|
||||
|
||||
@@ -140,7 +159,10 @@ class ProductDetailCategory(models.Model):
|
||||
|
||||
class Meta:
|
||||
verbose_name = 'دسته بندی جزيات'
|
||||
verbose_name_plural = 'دسته بندی های جزيیات'
|
||||
verbose_name_plural = 'دسته بندی های جزيیات'
|
||||
indexes = [
|
||||
models.Index(fields=['title'], name='detail_category_title_idx'),
|
||||
]
|
||||
|
||||
|
||||
|
||||
@@ -162,6 +184,13 @@ class CommentModel(models.Model):
|
||||
class Meta:
|
||||
verbose_name = 'نظر'
|
||||
verbose_name_plural = 'نظرات'
|
||||
indexes = [
|
||||
models.Index(fields=['product'], name='comment_product_idx'),
|
||||
models.Index(fields=['review_status'], name='comment_review_status_idx'),
|
||||
models.Index(fields=['product', 'review_status'], name='comment_product_status_idx'),
|
||||
models.Index(fields=['user'], name='comment_user_idx'),
|
||||
models.Index(fields=['timestamp'], name='comment_timestamp_idx'),
|
||||
]
|
||||
def __str__(self):
|
||||
return f"{self.user}-{self.content[:30]}"
|
||||
|
||||
@@ -205,6 +234,9 @@ class ProductDetailModel(models.Model):
|
||||
class Meta:
|
||||
verbose_name = 'جزیات محصول'
|
||||
verbose_name_plural = 'جزیات محصول ها'
|
||||
indexes = [
|
||||
models.Index(fields=['detail_category'], name='product_detail_category_idx'),
|
||||
]
|
||||
def __str__(self):
|
||||
return f'جزيیات محصول {self.detail_category.title} - {self.name}'
|
||||
|
||||
@@ -222,6 +254,10 @@ class DetailModel(models.Model):
|
||||
class Meta:
|
||||
verbose_name = 'مدل جزیات'
|
||||
verbose_name_plural = 'مدل های جزیات'
|
||||
indexes = [
|
||||
models.Index(fields=['detail_model'], name='detail_model_idx'),
|
||||
models.Index(fields=['title'], name='detail_title_idx'),
|
||||
]
|
||||
|
||||
|
||||
class ProductVariant(models.Model):
|
||||
@@ -250,6 +286,18 @@ class ProductVariant(models.Model):
|
||||
class Meta:
|
||||
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'),
|
||||
models.Index(fields=['price'], name='idx_price'),
|
||||
models.Index(fields=['discount'], name='product_variant_discount_idx'),
|
||||
models.Index(fields=['in_stock'], name='product_variant_in_stock_idx'),
|
||||
models.Index(fields=['product'], name='product_variant_product_idx'),
|
||||
models.Index(fields=['product', 'in_stock'], name='variant_product_stock_idx'),
|
||||
models.Index(fields=['product', 'discount'], name='variant_product_discount_idx'),
|
||||
]
|
||||
|
||||
def __str__(self):
|
||||
return f"{self.product.name} - {', '.join(str(attr) for attr in self.product_attributes.all())}"
|
||||
|
||||
Reference in New Issue
Block a user