i want to display a student profile from the database and am unable to do that.plz help

17 views
Skip to first unread message

rick

unread,
Jun 30, 2012, 2:54:35 PM6/30/12
to django...@googlegroups.com

this is my views.py.

def studentid(request):
    if request.method == 'POST':
        form = Student_loginForm(request.POST)
        if form.is_valid():
            cd = form.cleaned_data
            rollno = cd['rollno']
            p = form.save()
        rollno = request.POST.get('rollno')
        rollno=int(rollno)
        results = Add_record.objects.filter(Student_ID=rollno)
        return HttpResponseRedirect(reverse('record_system.views.search', args=(results)))


def search(request,Student_ID ):
    p = get_object_or_404(Add_record, pk=Student_ID)
    p.save()
    return render_to_response('add_record/search.html', locals(), context_instance=RequestContext(request))


and am getting error on browser that

NoReverseMatch at /record_system/studentid/

Reverse for 'record_system.views.search' with arguments '(<Add_record: Add_record object>,)' and keyword arguments '{}' not found.


thanks in advance..

Message has been deleted

manish girdhar

unread,
Jun 30, 2012, 11:33:38 PM6/30/12
to django...@googlegroups.com
hii..thanks for your concern friend....i did not able to get your point......can you please tell this in little more brief....actually i want to enter the roll number from the user and then that number could filter the data from the database and display the whole profile of the student..

On Sun, Jul 1, 2012 at 1:12 AM, Dennis Lee Bieber <wlf...@ix.netcom.com> wrote:
On Sat, 30 Jun 2012 11:54:35 -0700 (PDT), rick
<manishg...@gmail.com> declaimed the following in
gmane.comp.python.django.user:


>
> this is my views.py.
>
> def studentid(request):
>     if request.method == 'POST':
>         form = Student_loginForm(request.POST)
>         if form.is_valid():
>             cd = form.cleaned_data
>             rollno = cd['rollno']
>             p = form.save()
>         rollno = request.POST.get('rollno')
>         rollno=int(rollno)
>         results = Add_record.objects.filter(Student_ID=rollno)
>         return HttpResponseRedirect(reverse('record_system.views.search',
> args=(results)))

        Note: if args is supposed to be a tuple, you need to include a
trailing ,

                args = (results, )

        Otherwise, each item (if there are more than one) in results is
being treated as a separate positional argument.

        Other than that minor syntactic nit, one may need to see
"Add_record"...

        Also, what is the expected behavior if .is_valid() comes back false?

        As coded, regardless of the .is_valid() return, you appear to fetch
"rollno" from the request object (replacing any value saved from the
clean data branch).
--
        Wulfraed                 Dennis Lee Bieber         AF6VN
        wlf...@ix.netcom.com    HTTP://wlfraed.home.netcom.com/

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


Reply all
Reply to author
Forward
0 new messages