Exemplo n.º 1
0
def home_view(request):
    #del request.session['id']
    if request.method == "POST":
        search = StudentSearchForm(request.POST)
        if search.is_valid():
            value = search.cleaned_data.get('q')
            result = Student.objects.filter(student_name__contains=value)
            return render(request, 'home.html', {'result': result})
    else:
        form = StudentSearchForm()
        result = Student.objects.all()
        return render(request, 'home.html', {'form': form, 'result': result})
Exemplo n.º 2
0
def home(request):
    del request.session['id']
    if request.session == 1:
        if request.method=='POST':
            search=StudentSearchForm(request.POST)
            if search.is_valid():
                value=search.cleaned_data.get('q')
                result=Student.objects.filter(student_name=value)
                return render(request,'home.html',{'result':result,'form':StudentSearchForm()})
        else:
            form=StudentSearchForm()
            results=Student.objects.all()
            return render(request,'home.html',{'form':form,'results':results})
Exemplo n.º 3
0
def home_view(request):
    if request.method == 'POST':
        search = StudentSearchForm(request.POST)
        if search.is_valid():
            value = search.cleaned_data.get('q')
            result = Student.objects.filter(student_name__contains=value)
            return render(request, 'home.html', {
                'result': result,
                'form': StudentSearchForm()
            })
    else:
        form = StudentSearchForm()
        return render(request, 'home.html', {'form': form})

    #form1=StudentSearchForm()
    #form2=StudentDetailForm()
    #context={'form':form1,'details':form2}
    return render(request, 'home.html', context)