Tag Archives: django

Generic Django Model Search

I found a nice blog post that answered this question easily:

http://www.julienphalip.com/blog/2008/08/16/adding-search-django-site-snap/

So my code basically followed his and I was able to implement search on the Midwives Digital Library:

def search(request):
	query_string = ''
	found_entries = None
	if ('search' in request.GET) and request.GET['search'].strip():
			query_string = request.GET['search']
			entry_query = get_query(query_string, ['title'])
			found_entries = Resource.objects.filter(entry_query).order_by('id')

	return render_to_response('search.html',
						{ 'query_string': query_string, 'found_entries': found_entries },
						context_instance=RequestContext(request))

Very simple, and it works very nicely. The next step is to figure out how to search the PDFs. If the site was open, I’d let google do all the work… But they have copyright concerns… So off to avoid reinventing the wheel :)

Midwives College of Utah Digital Library Demo

In this screencast, I show how to administer the Midwives College Digital Library.  This little “Digital Library” app is the first Django application I’ve written. I’m really impressed and pleased with how easy it is to build a relatively useful application very quickly using Django.

Enjoy.