from django.contrib import admin
from apps.products.models import Category, Product


class ProductAdmin(admin.ModelAdmin):
    list_display = ["code", "name", "category_name", "is_active"]
    search_fields = ["code", "name"]

    def category_name(self, obj: Category) -> str:
        return obj.category.name
    category_name.short_description = 'Categoría'

# Register your models here.
admin.site.register(Product, ProductAdmin)
admin.site.register(Category)

from django.contrib import admin
from apps.products.models import Category, Product


class ProductAdmin(admin.ModelAdmin):
    list_display = ["code", "name", "category_name", "is_active"]
    search_fields = ["code", "name"]

    def category_name(self, obj: Category) -> str:
        return obj.category.name
    category_name.short_description = 'Categoría'

# Register your models here.
admin.site.register(Product, ProductAdmin)
admin.site.register(Category)

# Register your models here.