gur
gur

Reputation: 11

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 = RequestContext(request)

Upvotes: 0

Views: 345

Answers (1)

Silver Light
Silver Light

Reputation: 45902

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

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

Upvotes: 3

Related Questions