Answer the question
In order to leave comments, you need to log in
How to add tabs to django admin?
Here are 2 classes in the model:
class Cat(models.Model):
name = models.CharField("Название категории", max_length=128)
status = models.BooleanField('Статус')
attribute = models.ForeignKey('Atr', on_delete=models.CASCADE)
def __str__(self):
return self.name
class Meta:
verbose_name = "Категории"
verbose_name_plural = "Категория"
class Prod(models.Model):
title = models.CharField(max_length=100)
category = models.ForeignKey('Cat', on_delete=models.CASCADE)
image = models.ImageField("Изображение", blank=True)
status = models.BooleanField('Статус')
slug = models.SlugField(('ЧПУ'), max_length=60)
def __str__(self):
return self.title
class Meta:
verbose_name = "Товар"
verbose_name_plural = "Товары"
class CatAttributeInline(admin.TabularInline):
model = Prod
extra = 1
verbose_name_plural = 'Prod'
suit_classes = 'suit-tab suit-tab-params'
class CatAdmin(admin.ModelAdmin):
inlines = [CatAttributeInline]
serch_fields = ['id', 'name']
fieldsets = [
('General', {
'classes': ('suit-tab', 'suit-tab-general',),
'fields': ['name','status', 'attribute']
}),
]
suit_form_tabs = (('general', 'General'),
('params', 'Параметры'))
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question