These are the Apps added from the Model ClassDjango管理网站显示“XXXObject”的列表,而不是直接显示对象
I want it to directly display the details of the Object
的Leave_Details类的属性的详细日期,结束日期,详细.. 请点击图像链接。 我怎么能直接显示在首页>应用所有Leave_Object类的属性> Leave_statuss
显示它就像即在系统表
These are the Apps added from the Model ClassDjango管理网站显示“XXXObject”的列表,而不是直接显示对象
I want it to directly display the details of the Object
的Leave_Details类的属性的详细日期,结束日期,详细.. 请点击图像链接。 我怎么能直接显示在首页>应用所有Leave_Object类的属性> Leave_statuss
显示它就像即在系统表
你应该定义从admin.ModelAdmin
派生ADMIN类,并定义字段,如如下:
在您的应用程序的admin.py
定义
class LeaveDetailsAdmin(admin.ModelAdmin):
list_display = ['start_date', 'end_date']
admin.site.register(Leave_Details, LeaveDetailsAdmin)
RTFM :) - https://docs.djangoproject.com/en/1.10/ref/contrib/admin/ 更具体:https://docs.djangoproject.com/en/1.10/ref/contrib/admin/#modeladmin-objects
您需要实现
def __unicode__(self):
return self.[attribute_name]
内置的用户模型
将对象的名称作为attribute_name进行检索。
这是正确的答案 –
我想使它看起来像内部的用户页面,它显示一个适当的表格。 –
希望你使用Python 3.x所以你必须重写'__str__'而不是 –
list_display应该是一个元组..谢谢(y) –
啊,docs是这么说的。尽管,list_display也可以是一个列表 –