"""Change a ChoiceField select widget into a hidden field if the right GET variable is passed""" """ code for your view """ designation = request.GET.get('d') choice = {} if not designation: form = Form() else: """Setup the designation field as a hidden field if the right get variable was passed""" form = Form(initial={ 'designation': designation }) from django.forms import widgets for item in form.fields['designation'].choices: if str(item[0]) == designation: form.fields['designation'].widget = widgets.HiddenInput() choice['designation'] = str(item[1]) return render_to_response('my-form.html', { 'form': form, 'choice': choice }, context_instance=RequestContext(request)) """ code for your template """
{{ form.designation.label_tag }}{% if choice.designation %}{{ choice.designation }}{% endif %}{{ form.designation }}