4
我有一個頁面插入值到數據庫。 將正在加載另一個頁面的下拉列表的分貝值後,但 插入的值不會在下拉列表Django窗體緩存或重裝問題
的問題不在於交易/提交等來檢索降下來的數據中的查詢第二種形式是正確的。
Form1上(第一頁)
class Organization(forms.Form):
orgList = getOrgUnitList()
orgUnit = forms.CharField(label=u'Organization Name',
max_length=50,
error_messages={'required':'Organization name is required field.'})
parentOrg= forms.ChoiceField(label=u'Parent Organization',
choices=[(u'Select',u'Select')]+orgList,
error_messages={'required':'Organization name is required field.'})
窗體2(第二頁)
class User(forms.Form):
orgUnitList = getOrgUnitList()
email = forms.EmailField(label=u'Email',
max_length=50,
error_messages={'required':'Email is required field'})
orgUnit = forms.ChoiceField(label=u'Organizational Unit',
choices=orgUnitList,
error_messages={'required':'Organizational unit is required field'})
查詢
def getOrgUnitList():
orgUnitList = list(OrganizationUnit.objects.values_list
('OrgUnitID','OrgUnitName').order_by('OrgUnitName'))
return orgUnitList
但是當我試圖綁定鑑於它正在 工作代碼 * 視圖 *
def user()
template = get_template('AddUser.html')
form = AddUser()
orgUnitList = getOrgUnitList()
del objAdminUIDA
form.fields['orgUnit'].widget.choices=orgUnitList
variables = RequestContext(request,{'form':form})
output = template.render(variables)
del form
return HttpResponse(output)
的選擇,但我不能給下拉選擇鑑於我想在form.i需要一個解決方案給選擇form2
完全重複[Django表單重新加載數據(http://stackoverflow.com/questions/8485677/django -form-reload-data) –