I have a page to insert a value in db. After pasting, am loads another page with a dropdown list of db values ββBut the pasted value does not appear in the drop-down menu
The problem is not with transaction / commit, etc. The request for data for the drop-down list in the second form is correct.
Form 1 (first page)
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.'})
Form 2 (second page)
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'})
Query
def getOrgUnitList(): orgUnitList = list(OrganizationUnit.objects.values_list ('OrgUnitID','OrgUnitName').order_by('OrgUnitName')) return orgUnitList
but when I tried to bind the selected options, it works working code * View *
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)
But I cannot give a drop-down choice; I want to give a choice in form. I need a solution for form2
source share