我正在尝试在窗体字段中使用自动完成灯光。
当我试图使用我得到的领域
FieldError at /autocomplete/icd_10Autocomplete/
Cannot resolve keyword u'name' into field. Choices are: icd_10_code, icd_10_desc, id
icd_10_code, icd_10_desc, id
是icd10表中的字段,但我只想从icd_10_codes
字段中检索数据。你知道吗
诊断模型中的icd\u10编码是icd\u10.icd\u10.code字段中的一个外键。当我试图在诊断.icd\u 10\u代码我希望表单自动完成单词,查找存储在icd\u 10.icd\u 10\u代码字段中的单词。你知道吗
你知道吗?你知道吗
表单.py
import autocomplete_light
autocomplete_light.register(icd_10)
autocomplete_light.autodiscover()
class DiagnosisForm(forms.ModelForm):
def __init__(self, *args, **kwargs):
super(DiagnosisForm, self).__init__(*args, **kwargs)
self.helper=FormHelper(self)
self.fields['icd_10_code']= forms.ModelChoiceField(queryset=icd_10, widget=autocomplete_light.ChoiceWidget("icd_10Autocomplete"))
self.helper.layout = Layout(
# 'patient',
'age_of_diagnosis',
'icd_10_code',
FormActions(
Submit('submit', "Save changes"),
Submit('cancel',"Cancel")
),
)
self.helper.form_tag = False
self.helper.form_show_labels = True
class Meta:
model = Diagnosis
对于
ModelForm
,您应该使用如果不希望将模型字段传递给窗体。您可以在这个元组中包含任何其他不应该转到窗体的字段。否则,表单希望用户无论如何都应该为这些字段提供一个值。你知道吗
你在什么时间点收到错误,什么是潜在的
Diagnosis
模型,也不是很清楚。你知道吗相关问题 更多 >
编程相关推荐