【发布时间】:2013-04-03 16:44:09
【问题描述】:
class FilterForm(forms.Form):
currency = forms.ChoiceField(choices=Currency_choices)
continent = forms.ChoiceField(choices=Select_continent())
def clean_country(self):
continent = self.cleaned_data['continent']
result = Select_country(continent)
return result
country = forms.ChoiceField(choices=clean_country()) //error is here
我正在尝试获取 Continent 中的选定字段并显示该大陆的所有国家/地区 所以尝试使用 clean_country 返回所选大陆的国家列表。 但我有 TypeError : clean_country() 只需要 1 个参数(给定 0) 那么如何使用这个功能呢?
【问题讨论】:
-
你根本不想在那里使用它。我认为您要做的是有一个表格,当您为“大陆”填写特定值时,将通过填写国家/地区的可能值来响应。但是您绝对不能以这种方式仅在服务器端这样做。也许您应该为您的问题添加更多解释和上下文。
标签: python django forms class self