【发布时间】:2017-02-28 05:05:59
【问题描述】:
我正在使用 Django 表单来显示数据。
有一个 HTML 选择字段 - 它有 2 个选项 a) 教师和 b) 学生。
Django 表单:-
self.fields['account_type'].choices = [('student','Student'),('teacher', 'Teacher')]
self.helper.layout = Layout(
HTML('''<h5>Sign Up Information</h5>'''),
Div(
Field('account_type', placeholder="Account Type", css_class='form-control'),
css_class = 'form-group'
),
根据您选择“学生”还是“教师”,您需要自动填充另一个字段 - 主题。如何在 Django 表单中触发“onchange”事件。
【问题讨论】: