36 lines
1.2 KiB
Python
36 lines
1.2 KiB
Python
from django.contrib import admin
|
|
from .models import Category, Website, Product, ProductPrice
|
|
|
|
|
|
@admin.register(Category)
|
|
class CategoryAdmin(admin.ModelAdmin):
|
|
list_display = ['id', 'name', 'slug', 'parent', 'sort_order', 'created_at']
|
|
list_filter = ['parent']
|
|
search_fields = ['name', 'slug']
|
|
prepopulated_fields = {'slug': ('name',)}
|
|
ordering = ['sort_order', 'id']
|
|
|
|
|
|
@admin.register(Website)
|
|
class WebsiteAdmin(admin.ModelAdmin):
|
|
list_display = ['id', 'name', 'url', 'category', 'rating', 'is_verified', 'sort_order']
|
|
list_filter = ['category', 'is_verified']
|
|
search_fields = ['name', 'url']
|
|
ordering = ['sort_order', 'id']
|
|
|
|
|
|
@admin.register(Product)
|
|
class ProductAdmin(admin.ModelAdmin):
|
|
list_display = ['id', 'name', 'category', 'created_at', 'updated_at']
|
|
list_filter = ['category']
|
|
search_fields = ['name', 'description']
|
|
ordering = ['-created_at']
|
|
|
|
|
|
@admin.register(ProductPrice)
|
|
class ProductPriceAdmin(admin.ModelAdmin):
|
|
list_display = ['id', 'product', 'website', 'price', 'original_price', 'in_stock', 'last_checked']
|
|
list_filter = ['website', 'in_stock', 'currency']
|
|
search_fields = ['product__name', 'website__name']
|
|
ordering = ['-updated_at']
|