我有两个与ManyToManyField关系相关的Django模型。一切正常,除了内联添加下拉列表,它列出了丑陋的自动创建的对象名称,而不是允许我格式化它。我该如何指定?
型号:
class ScheduleAdmin(admin.ModelAdmin):
list_display = ['id', 'title', 'start_time', 'end_time', 'repeat_unit', 'repeat_every', 'repeat_max_count']
class ScheduleInline(admin.TabularInline):
model = Schedule.job.through
min_num = 0
extra = 0
# fields = ('title', )
verbose_name = "Schedule"
verbose_name_plural = "Schedules"
class JobAdmin(admin.ModelAdmin):
list_display = ['id', 'type', 'guid', 'title', 'started_time', 'ended_time', 'enabled', 'running', 'progress']
inlines = [ScheduleInline,]
admin.site.register(Schedule, ScheduleAdmin)
admin.site.register(Job, JobAdmin)
管理
{{1}}
并且,当我点击内联下拉菜单时,我得到: https://stackoverflow.com/a/5112638/5790669
答案 0 :(得分:1)
从__unicode__(self)
更改为__str__(self)
做了诀窍