readonly_fields = ['prop', 'value']
def has_add_permission(self, request):
return False
class PropertyProductForm(forms.ModelForm):
value = forms.ModelChoiceField(queryset=PropertyVariant.objects.all(), empty_label="(Нет)")
class PropertyVariantAdmin(admin.TabularInline):
model = PropertyVariant
readonly_fields = ['guid', ]
# fk_name = 'property_product'
extra = 0
@admin.register(Prop)
class PropAdmin(admin.ModelAdmin):
readonly_fields = ['guid', ]
inlines = [PropertyVariantAdmin]
class PropertyProductAdmin(admin.TabularInline):
model = PropertyProduct
form = PropertyProductForm
extra = 0
readonly_fields = ['prop', 'value']
def has_add_permission(self, request):
return False
class ProductAdmin(admin.ModelAdmin):
list_display = ['__str__', 'slug', 'item_number', 'group', 'active', 'country', 'quantity']
readonly_fields = ['guid', ]
prepopulated_fields = {"slug": ["name"]}
fields = (
('name', 'slug', 'item_number'),
('featured', 'active', 'is_set', 'is_new'),
('description',),
('group', 'country', 'unit', 'quantity'),
('meta_title', 'meta_descriptions'),
)
# formfield_overrides = {
# TextField: {'widget': AdminMartorWidget},
# }
inlines = [PropertyProductAdmin]
if self.article == 'foo':
return "templates/foo.html