It doesn't ever work since you should rerender form with current data
and errors if form.valid() returns false.
Currently your logic doesn't return _nothing_ if form.valid() is false
def studentid(request):
if request.method == 'POST':
form = Student_loginForm(request.POST)
if form.is_valid():
cd = form.cleaned_data
rollno = cd['rollno']
return
HttpResponseRedirect(reverse('record_system.views.search' , args=(rollno)))
# No else here, nothing is rendered!
else:
# This else is for if request.method == POST
form = Student_loginForm()
return render_to_response('add_record/studentid.html',
context_instance=RequestContext(request))
I suggest that you put last return one indent level to left so it will
always render either errored form or in case method was not POST empty form.
6.7.2012 12:31, manish girdhar kirjoitti:
> thanks for the concern firend but i already have an form.error in my
> template.......
>
>
> *this is my template..
> *
> <mailto:
ka...@sutt.ee <mailto:
ka...@sutt.ee>>> wrote:
>
> There is no HttpResponse object returned if the form is
> *not* valid.
>
> You might want to return a template saying that the form
> input was
> incorrect.
>
> Tervitades/Regards
> Karl Sutt
>
>
>
> On Fri, Jul 6, 2012 at 11:49 AM, manish girdhar
> <
manishg...@gmail.com
> <mailto:
manishg...@gmail.com>
> <mailto:
manishgirdhar88@gmail.__com
> <mailto:
manishg...@gmail.com>>> wrote:
>
> hii tom,
> yeah i have rectidy rollno = cd["rollno"] ,but again am
> getting
> error didn't get an httpresponse object...
>
> this is my view.
>
>
> def studentid(request):
> if request.method == 'POST':
> form = Student_loginForm(request.__POST)
> if form.is_valid():
> cd = form.cleaned_data
> rollno = cd['rollno']
> return
>
> HttpResponseRedirect(reverse('__record_system.views.search' ,
> args=(rollno)))
> else:
> form = Student_loginForm()
>
> return
> render_to_response('add___record/studentid.html',
> context_instance=__RequestContext(request))
>
>
> the error is in*"if form.is_valid: "*..its getting
> false and
>
> ultimately the further process is not going on..
>
> thanks in advance.
>
>
> On Thu, Jul 5, 2012 at 7:34 PM, Tom Evans
> <
teva...@googlemail.com
> <mailto:
teva...@googlemail.com>
> <mailto:
tevans.uk@googlemail.__com
> <mailto:
manishg...@gmail.com>
> <mailto:
manishgirdhar88@gmail.__com
> <mailto:
manishg...@gmail.com>>> wrote:
> > yes it was indentation error and i rectified
> that.thanks
> for the concern
> > friend..
> >
>
> I would have thought that it was you refering to
> the undefined
> variable rollno here:
>
> cd = form.cleaned_data
> rollno = cd[rollno]
> rollno = request.POST.get(rollno)
>
> Should it not read:
>
> cd = form.cleaned_data
> rollno = cd["rollno"]
> rollno = request.POST.get(rollno)
>
> Cheers
>
> Tom
>
> --
> You received this message because you are
> subscribed to the
> Google Groups "Django users" group.
> To post to this group, send email to
>
django...@googlegroups.com <mailto:
django...@googlegroups.com>
> <mailto:
django-users@__
googlegroups.com
> <mailto:
django...@googlegroups.com>>.
>
> To unsubscribe from this group, send email to
> django-users+unsubscribe@__
googlegroups.com
> <mailto:
django-users%2Bunsu...@googlegroups.com>
>
> <mailto:
django-users%__2Buns...@googlegroups.com
> <mailto:
django-users%252Buns...@googlegroups.com>__>.
>
> For more options, visit this group at
>
http://groups.google.com/__group/django-users?hl=en
> <
http://groups.google.com/group/django-users?hl=en>.
>
>
> --
> You received this message because you are subscribed to the
> Google Groups "Django users" group.
> To post to this group, send email to
>
django...@googlegroups.com <mailto:
django...@googlegroups.com>
> <mailto:
django-users@__
googlegroups.com
> <mailto:
django...@googlegroups.com>>.
>
> To unsubscribe from this group, send email to
> django-users+unsubscribe@__
googlegroups.com
> <mailto:
django-users%2Bunsu...@googlegroups.com>
> <mailto:
django-users%__2Buns...@googlegroups.com
> <mailto:
django-users%252Buns...@googlegroups.com>__>.
>
> For more options, visit this group at
>
http://groups.google.com/__group/django-users?hl=en
> <
http://groups.google.com/group/django-users?hl=en>.
>
>
> --
> You received this message because you are subscribed to the
> Google
> Groups "Django users" group.
> To post to this group, send email to
>
django...@googlegroups.com <mailto:
django...@googlegroups.com>
> <mailto:
django-users@__
googlegroups.com
> <mailto:
django...@googlegroups.com>>.
>
> To unsubscribe from this group, send email to
> django-users+unsubscribe@__
googlegroups.com
> <mailto:
django-users%2Bunsu...@googlegroups.com>
> <mailto:
django-users%__2Buns...@googlegroups.com
> <mailto:
django-users%252Buns...@googlegroups.com>__>.
>
> For more options, visit this group at
>
http://groups.google.com/__group/django-users?hl=en
> <
http://groups.google.com/group/django-users?hl=en>.
>
>
> --
> You received this message because you are subscribed to the Google
> Groups "Django users" group.
> To post to this group, send email to
>
django...@googlegroups.com
> <mailto:
django...@googlegroups.com>.
> To unsubscribe from this group, send email to
> django-users+unsubscribe@__
googlegroups.com
>
http://groups.google.com/__group/django-users?hl=en
> <
http://groups.google.com/group/django-users?hl=en>.
>
>
> --
> Jani Tiainen
>
> - Well planned is half done and a half done has been sufficient
> before...
>
>
>
> --
> You received this message because you are subscribed to the Google
> Groups "Django users" group.
> To post to this group, send email to
django...@googlegroups.com
> <mailto:
django...@googlegroups.com>.
> To unsubscribe from this group, send email to
> django-users+unsubscribe@__
googlegroups.com
>
http://groups.google.com/__group/django-users?hl=en
> <
http://groups.google.com/group/django-users?hl=en>.
>
>
> --
> You received this message because you are subscribed to the Google
> Groups "Django users" group.
> To post to this group, send email to
django...@googlegroups.com.
> To unsubscribe from this group, send email to
>
django-users...@googlegroups.com.