开发者

django.. select query

I want to search the male and female in my database and then display.

Actually my using radio button for male and female now i want when i select the male it will fetch all the male from database and then display and if select female vice-versa.

I don't konw how to use select query in django.

def search(request):
    search_gender = request.POST["gender"]

    if (search_gender == 'female'):
        Psear = PatientInfo.objects.get(gender__iexact='female')

        template = "../templates/admin/search.html"
        data = {'patientinfo_all': Psear,}
        return render_to_response( template, data, context_instance开发者_JAVA技巧 = RequestContext(request)


get() method will return only one row, you are actually looking for filter():

Psear = PatientInfo.objects.filter(gender__iexact='female')
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜