嗨说我的module.py中有一个地址字段,如下所示,
class Employee(models.Model):
name = models.CharField(max_length = 100,verbose_name="Name")
Add1 = models.CharField(max_length = 100,verbose_name="Line 1")
Add2 = models.CharField(max_length = 100,verbose_name="Line 2")
city = models.CharField(max_length = 100,verbose_name="City")
Zip_code = models.CharField(max_length = 100,verbose_name="ZIP CODE")
现在在管理员表单中,如何在一个类别下显示所有内容,如下所示,
ADDRESS:
LINE 1:
LINE 2:
CITY:
ZIP CODE:
答案 0 :(得分:1)
使用fieldsets。
在admin.py中:
class YourAdmin(admin.ModelAdmin):
fieldsets = (
(None, {
'fields': ('name',)
}),
('Address', {
'fields': ('Add1', 'Add2', 'city', 'zipcode',)
}),
)