如何在django管理面板中为formset中的每个表单添加计数。我需要为每个新添加的表格提供下一个号码
class QuestionAnswerInline(admin.TabularInline):
model = QuestionAnswer
formset = SetTestQuestionAnswerFormSet
fields = ('question_answer_text','right_mark')
class QuestionAdmin(admin.ModelAdmin):
fieldsets = [
...
]
inlines = [QuestionAnswerInline]
答案 0 :(得分:1)
有两种方法可以做到这一点: