so sorry friend..am new to the django and am unable to catch your point...can you please describe this with example or with my code..thank you..
On Fri, Jul 6, 2012 at 3:08 PM, Jani Tiainen <rede...@gmail.com> wrote: > 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.. >> >> * >> <html> >> <head> >> <title>student id</title> >> </head> >> >> <body style="background-color:pink;"**> >> {% if form.errors %} >> <p style="color: red;"> >> Please correct the error{{ form.errors|pluralize }} below. >> </p> >> {% endif %} >> <h1><center>STUDENT RECORD SYSTEM</center></h1> >> <hr> >> <form action="" method="post"> >> {% csrf_token %} >> >> <table><tr><td>Student Roll no:</td> >> <td><input type="text" name="rollno"></td><br /></tr></table> >> <input type="submit" value="Submit"> >> </form> >> >> >> >> </body> >> </html> >> >> >> On Fri, Jul 6, 2012 at 2:49 PM, Jani Tiainen <rede...@gmail.com >> <mailto:rede...@gmail.com>> wrote: >> >> Print out form.errors it will contain dictionary about fields and >> errors in particular field. >> >> You get the error because your form didn't validate in the first >> place so either you have bad data, are missing required data or >> something else in validation fails. form.errors will reveal that. >> >> 6.7.2012 12:16, manish girdhar kirjoitti: >> >> thank you for your concern friend,but i have an another view .in >> that it >> perfectly works....but here am getting problem and i know >> >> *"if form.is_valid():"* is getting false....what am looking for >> is >> >> this, that why here am getting problem. >> this thing perfectlly works in my adding two number view's >> appication. >> >> >> On Fri, Jul 6, 2012 at 2:35 PM, Karl Sutt <k...@sutt.ee >> <mailto:k...@sutt.ee> >> <mailto:k...@sutt.ee <mailto:k...@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 >> <manishgirdha...@gmail.com >> <mailto:manishgirdhar88@gmail.**com <manishgirdha...@gmail.com>> >> <mailto:manishgirdhar88@gmail.**__com >> >> <mailto:manishgirdhar88@gmail.**com <manishgirdha...@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 >> <tevans...@googlemail.com >> <mailto:tevans.uk@googlemail.**com <tevans...@googlemail.com>> >> <mailto:tevans.uk@googlemail._**_com >> >> <mailto:tevans.uk@googlemail.**com <tevans...@googlemail.com>>>> >> wrote: >> >> On Thu, Jul 5, 2012 at 8:38 AM, manish girdhar >> <manishgirdha...@gmail.com >> <mailto:manishgirdhar88@gmail.**com <manishgirdha...@gmail.com>> >> <mailto:manishgirdhar88@gmail.**__com >> >> <mailto:manishgirdhar88@gmail.**com <manishgirdha...@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-users@googlegroups.com <mailto:django-users@** >> googlegroups.com <django-users@googlegroups.com>> >> >> <mailto:django-users@__googleg**roups.com<http://googlegroups.com> >> >> >> <mailto:django-users@**googlegroups.com<django-users@googlegroups.com> >> >>. >> >> To unsubscribe from this group, send email to >> >> django-users+unsubscribe@__goo**glegroups.com<http://googlegroups.com> >> >> <mailto:django-users%**2bunsubscr...@googlegroups.com<django-users%252bunsubscr...@googlegroups.com> >> **> >> >> >> <mailto:django-users%__**2bunsubscr...@googlegroups.com<django-users%25__2bunsubscr...@googlegroups.com> >> >> <mailto:django-users%**252Bunsubscribe@googlegroups.**com<django-users%25252bunsubscr...@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> >> >> <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-users@googlegroups.com <mailto:django-users@** >> googlegroups.com <django-users@googlegroups.com>> >> >> <mailto:django-users@__googleg**roups.com<http://googlegroups.com> >> >> >> <mailto:django-users@**googlegroups.com<django-users@googlegroups.com> >> >>. >> >> To unsubscribe from this group, send email to >> >> django-users+unsubscribe@__goo**glegroups.com<http://googlegroups.com> >> >> <mailto:django-users%**2bunsubscr...@googlegroups.com<django-users%252bunsubscr...@googlegroups.com> >> **> >> >> <mailto:django-users%__**2bunsubscr...@googlegroups.com<django-users%25__2bunsubscr...@googlegroups.com> >> >> <mailto:django-users%**252Bunsubscribe@googlegroups.**com<django-users%25252bunsubscr...@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> >> >> <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-users@googlegroups.com <mailto:django-users@** >> googlegroups.com <django-users@googlegroups.com>> >> >> <mailto:django-users@__googleg**roups.com<http://googlegroups.com> >> >> >> <mailto:django-users@**googlegroups.com<django-users@googlegroups.com> >> >>. >> >> To unsubscribe from this group, send email to >> >> django-users+unsubscribe@__goo**glegroups.com<http://googlegroups.com> >> >> <mailto:django-users%**2bunsubscr...@googlegroups.com<django-users%252bunsubscr...@googlegroups.com> >> **> >> >> <mailto:django-users%__**2bunsubscr...@googlegroups.com<django-users%25__2bunsubscr...@googlegroups.com> >> >> <mailto:django-users%**252Bunsubscribe@googlegroups.**com<django-users%25252bunsubscr...@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> >> >> <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-users@googlegroups.com >> >> <mailto:django-users@**googlegroups.com<django-users@googlegroups.com> >> >. >> To unsubscribe from this group, send email to >> >> django-users+unsubscribe@__goo**glegroups.com<http://googlegroups.com> >> >> >> <mailto:django-users%**2bunsubscr...@googlegroups.com<django-users%252bunsubscr...@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> >> >> <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-users@googlegroups.com >> >> <mailto:django-users@**googlegroups.com<django-users@googlegroups.com> >> >. >> To unsubscribe from this group, send email to >> django-users+unsubscribe@__goo**glegroups.com<http://googlegroups.com> >> >> >> <mailto:django-users%**2bunsubscr...@googlegroups.com<django-users%252bunsubscr...@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> >> >> <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-users@googlegroups.com. >> To unsubscribe from this group, send email to >> django-users+unsubscribe@**googlegroups.com<django-users%2bunsubscr...@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> >> . >> > > > -- > 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-users@googlegroups.com. > To unsubscribe from this group, send email to django-users+unsubscribe@** > googlegroups.com <django-users%2bunsubscr...@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-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.