Friday, July 30, 2010

Re: Form Validation

Here's the view template:

def respondant(request):

user = request.user

if set(RESPONDANT_FIELDS).issubset(set([key for key,value in
request.POST.items()])):
form = RespondantForm(request.POST)
if form.is_valid():
form.save()
template = "feedback/success.html"
else:
form = RespondantForm()
return render_to_response('feedback/index.html', {
'form': form,
})

else:
key = request.REQUEST.get('key')
if key:
respondant = Respondant.objects.check_key(key)
else:
form = RespondantForm()
return render_to_response('feedback/index.html', {
'form': form,
})

return render_to_response(template)

On Jul 30, 11:44 am, Daniel Roseman <dan...@roseman.org.uk> wrote:
> On Jul 30, 4:42 pm, rupert <evan.fer...@gmail.com> wrote:
>
> > I'm trying to use this line of code in form validation, and it is not
> > working:
>
> > {{ form.field_name.errors }}
>
> > The following lines do output:
> > {{ form.filed_name}}
> > {{ form.field_name.help_text }}
>
> > Any thoughts? Could it be something in the view?
>
> Very likely. Has the form been validated?
> --
> DR.

--
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 django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

No comments:

Post a Comment