D
D
Denis Pupchenko2017-04-15 18:27:35
Django
Denis Pupchenko, 2017-04-15 18:27:35

How can I make sure that when select is selected, only the corresponding inlines are displayed in the admin panel?

82ba7dfe811246d598e1aef22fbb2fda.png
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 question

Ask a Question

731 491 924 answers to any question