On Wed, Feb 23, 2011 at 4:23 PM, Akshit Khurana <axitkhur...@gmail.com> wrote: > I want to search from database and return objects in order (soft_name, > category and subcategory are fields of a model) > 1st if soft_name has query > then if category has query > and then if subcategory has query > I've written this: > query = request.GET.get('q','') > if query: > qset = ( > Q(soft_name__icontains=query) | > Q(category__icontains=query) | > Q(subcategory__icontains=query) | > ) > results = Software.objects.filter(qset).distinct() > But this returns mixed results (not in required order) > Is it possible to obtain results in order without writing 3 queries and > joining the resultant lists? > Thanks > Akshit >
http://docs.djangoproject.com/en/1.2/ref/models/querysets/#order-by HTH Tom -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@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.