I am using this query in the views function search() to find a lawyer in the database:
lawyers = Lawyer.objects.filter(last__icontains=q) q is the query entered by user here: http://swimswith.com/search-form/ For instance, searching for "lelland" returns her info: http://swimswith.com/search/?q=delelle But instead of returning that info, I want to grab the school info and year_graduated for "delelle" and search again and find all lawyers who graduated from the same school the same year and display that. Can anyone help about how to do this? This is the view def search(request): if 'q' in request.GET and request.GET['q']: q = request.GET['q'] lawyers = Lawyer.objects.filter(last__icontains=q) return render_to_response('search_results.html', {'lawyers': lawyers, 'query': q}) else: return HttpResponse('Please submit a search term.') This is the model: from django.db import models class Lawyer(models.Model): firm_url = models.CharField('Bio', max_length=200) firm_name = models.CharField('Firm', max_length=100) first = models.CharField('First Name', max_length=50) last = models.CharField('Last Name', max_length=50) year_graduated = models.IntegerField('Year graduated') school = models.CharField(max_length=300) class Meta: ordering = ('last',) def __unicode__(self): return self.first Also in stackoverflow: http://stackoverflow.com/questions/2058573/how-to-refine-an-initial-query-in-django Thanks for your help!
-- 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.