I am trying to use a customer manipulator to build a search screen. One
of my
fields is a select field but I get an error to many values to unpack.
Any help would be greatly appreciated.
views.py
class SearchResults(forms.Manipulator):
def __init__(self):
projects = ['Gen2', 'CRMC']
self.fields = (
forms.TextField(field_name="resultsid"),
forms.TextField(field_name="testname", length=30),
forms.TextField(field_name="startdate"),
forms.TextField(field_name="enddate"),
forms.TextField(field_name="submitdate"),
forms.TextField(field_name="submitenddate"),
forms.TextField(field_name="owner"),
forms.SelectField(field_name="project", choices=projects),
}
def create_results(request):
manipulator = Results.AddManipulator()
if request.method == 'POST':
# If data was POSTed, we're trying to create a new Results.
new_data = request.POST.copy()
# Check for errors.
errors = manipulator.get_validation_errors(new_data)
if not errors:
# No errors. This means we can save the data!
manipulator.do_html2python(new_data)
new_results = manipulator.save(new_data)
# Redirect to the object's "edit" page. Always use a
redirect
# after POST data, so that reloads don't accidently create
# duplicate entires, and so users don't see the confusing
# "Repost POST data?" alert box in their browsers.
return HttpResponseRedirect("/results/edit/%i/" %
new_results.id)
else:
# No POST, so we want a brand new form without any data or
errors.
errors = new_data = {}
# Create the FormWrapper, template, context, response.
form = forms.FormWrapper(manipulator, new_data, errors)
return render_to_response('results/create_form.html', {'form':
form})
Thanks,
Jeff
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---