Answer the question
In order to leave comments, you need to log in
How can I make sure that when select is selected, only the corresponding inlines are displayed in the admin panel?
admin.py
class AnswerInline(admin.StackedInline):
fields = ('answer_text','points')
readonly_fields = ('question',)
extra = 0
class AnswerRadioInline(AnswerInline):
model = AnswerRadio
class AnswerSelectMultipleInline(AnswerInline):
model = AnswerSelectMultiple
class AnswerTextInline(AnswerInline):
model= AnswerText
class QuestionAdmin(admin.ModelAdmin):
inlines = [AnswerRadioInline,AnswerSelectMultipleInline,AnswerTextInline,]
admin.site.register(Question, QuestionAdmin)
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question