我想在django-admin的过滤器区域中添加一个额外的字段。目前在日期字段中,它仅显示过去7天的今天等。我还需要在该字段中显示“明天”字段。有没有办法在外面添加这个东西?
这是我的管理员:
class ParcareModelAdmin(admin.ModelAdmin):
list_display = [ "email","user", "location",
"parking_on", "parking_off", "venire", "plecare"]
list_display_links = ["email", "user" ]
list_editable = [ "parking_off", "parking_on","venire", "plecare"]
list_filter = ["parking_on", "parking_off"]
search_fields = ["location", "name"]
date_hierarchy='parking_on'
class Meta:
model = Parcare
# def email(self, obj):
# return obj.user.email
def get_form(self, request, obj=None, **kwargs):
form = super().get_form(request, obj, **kwargs)
if not obj:
user = request.user
form.base_fields['user'].initial = user
form.base_fields['email'].initial = user.email
return form
admin.site.register(Parcare, ParcareModelAdmin)
答案 0 :(得分:0)
date_hierarchy='parking_on'