add color field and in stuck model

This commit is contained in:
Parsa Nazer
2025-02-01 19:34:03 +03:30
parent 14655faf20
commit 8b5ee6dbf8
11 changed files with 213 additions and 4 deletions
+11 -2
View File
@@ -1,18 +1,27 @@
from django.contrib import admin
from .models import *
from unfold.admin import ModelAdmin
from unfold.admin import ModelAdmin, TabularInline
from import_export.admin import ImportExportModelAdmin
from unfold.contrib.import_export.forms import ExportForm, ImportForm, SelectableFieldsExportForm
from unfold.contrib.forms.widgets import ArrayWidget, WysiwygWidget
from django.contrib.postgres.fields import ArrayField
from unfold.widgets import (
UnfoldAdminColorInputWidget,
)
class InStuckColorsInLine(TabularInline):
model = InStuckColors
extra = 1
formfield_overrides = {
models.CharField: {"widget": UnfoldAdminColorInputWidget()},
}
@admin.register(ProductModel)
class ProductModelAdmin(ModelAdmin, ImportExportModelAdmin):
import_form_class = ImportForm
export_form_class = ExportForm
inlines = [InStuckColorsInLine]
readonly_fields = ('slug', )
compressed_fields = True