hi I want to use this mysql Query " SELECT count(*) as class_roll_no FROM student_profile where class_roll_no !='00 ' "; in my view file
Is it possible? I try this code view.py file is : from django.shortcuts import render_to_response from mysite.student.models import Profile from django.db.models import Count def fulldetail(request): fulldetail = Profile.objects.all().order_by('class_roll_no') total_count = Profile.objects.filter( class_roll_no !='00') total = total_count.count() return render_to_response("userprofile/profile/fulldetail.html", {"fulldetail" : fulldetail, "total":total} ) Is this correct way to use this? if not please help or give any tutorials how to use mysql quires with some conditions. template file code is: Total = {{ total }} <table > <tr><th>PHOTO<th>NAME<th>ROLL NO<th>BRANCH</tr></thead> {% if fulldetail %} {% for part in fulldetail %} {% if part.firstname %} <tr><td>{% if part.photo %} <img src="{{ part.photo.url }}" height="50" />{% endif %}<td>{{ part.firstname }} {{ part.middlename }} {{ part.lastname }}</ a><td>{{ part.class_roll_no}}</a> <td>{{ part.branch }}</tr> {% endif %} {% endfor %} {% else %} <p> Data is Not available.</p> {% endif %} </td></tr> </table> I only count number of entry with condition. Thanks -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@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.