我有模特:
class Acessories(models.Model):
clother = models.ForeignKey(Clother, on_delete=models.CASCADE)
acessories_type = models.ForeignKey(AcessoriesType, on_delete=models.CASCADE)
name = models.CharField(max_length=30, blank=True)
class Clother(models.Model):
MALE = 'MA'
FEMALE = 'FE'
UNISEX = 'UN'
GENDER_CHOICES = ((MALE, 'Male'), (FEMALE, 'Female'), (UNISEX, 'Unisex'))
commodity = models.ForeignKey(Commodity, related_name='commodity', on_delete=models.CASCADE)
color = models.ManyToManyField(Commodity, related_name='color')
material = models.ManyToManyField(Commodity, related_name='material')
gender = models.CharField(max_length=2, choices=GENDER_CHOICES, default=UNISEX)
如何在一个管理员界面中制作? 需要查看和编辑它,因为它是一个模型。 谢谢!
答案 0 :(得分:0)
尝试此操作或访问此link以获取更多信息
class AccessoryInline(admin.TabularInline):
model = Acessories
@admin.register(Clothes)
class ClothesAdmin(admin.ModelAdmin):
inlines = [
AccessoryInline,
]