delete mathod qoshildi

This commit is contained in:
Husanjonazamov
2026-03-31 12:06:36 +05:00
parent 8601d123ed
commit a7c8c80d29
3 changed files with 14 additions and 9 deletions

View File

@@ -6,6 +6,7 @@ from core.apps.api.models import CategoryModel, FilialModel, SubcategoryModel
class SubcategoryInline(TabularInline):
model = SubcategoryModel
extra = 1
autocomplete_fields = ("category",)
@admin.register(FilialModel)
@@ -19,16 +20,18 @@ class FilialAdmin(ModelAdmin):
class CategoryAdmin(ModelAdmin):
list_display = ("id", "name", "filial", "order", "image", "active_image", "created_at")
list_editable = ("order",)
list_filter = ("filial", "created_at")
search_fields = ("name",)
list_filter = ("filial", "type", "created_at")
search_fields = ("name", "filial__name", "type")
list_select_related = ("filial",)
ordering = ("order",)
autocomplete_fields = ("filial",)
inlines = [SubcategoryInline]
@admin.register(SubcategoryModel)
class SubcategoryAdmin(ModelAdmin):
list_display = ("id", "name", "category", "created_at")
list_filter = ("category", "category__filial", "created_at")
search_fields = ("name", "category__name")
list_select_related = ("category",)
list_filter = ("category__filial", "category", "created_at")
search_fields = ("name", "category__name", "category__filial__name")
list_select_related = ("category", "category__filial")
autocomplete_fields = ("category",)

View File

@@ -11,9 +11,10 @@ class SubProductInline(TabularInline):
@admin.register(ProductsModel)
class ProductsAdmin(ModelAdmin):
list_display = ("id", "name", "price", "image", "subcategory", "created_at")
list_filter = ("subcategory", "subcategory__category", "subcategory__category__filial", "created_at")
search_fields = ("name", "subcategory__name")
list_select_related = ("subcategory", "subcategory__category")
list_filter = ("subcategory__category__filial", "subcategory__category", "subcategory", "created_at")
search_fields = ("name", "subcategory__name", "subcategory__category__name")
list_select_related = ("subcategory", "subcategory__category", "subcategory__category__filial")
autocomplete_fields = ("subcategory",)
inlines = [SubProductInline]

View File

@@ -48,7 +48,8 @@ class CategoryModel(AbstractBaseModel):
order = models.PositiveIntegerField(verbose_name=_("order"), default=0)
def __str__(self):
return f"{self.name} ({self.type})"
filial_name = self.filial.name if self.filial else "Filial yo'q"
return f"{self.name} ({self.type}) - {filial_name}"
@classmethod
def _baker(cls):