How to make custom field (defined as function) in StackedInline hidden?

10 views
Skip to first unread message

Mirek Zvolsky

unread,
Sep 9, 2018, 7:14:04 AM9/9/18
to Django users
Django 2.1.

I have this code:

class AnswerInline(admin.StackedInline):
    model
= Answer
    form
= AnswerForm
    fields
= ("question_answer_type", "answer_plain")
    readonly_fields
= ("question_answer_type",)

def question_answer_type(self, row):
   
return row.question.answer_type

This works and I have new field "question_answer_type" in inline instances.

Now I want to make this field hidden. (I want use its content in JavaScript.)

I know there is forms.widgets.HiddenInput (or forms.HiddenInput ???) which I should probably use. But how to use it?

Reply all
Reply to author
Forward
0 new messages