Note that there are some explanatory texts on larger screens.

plurals
  1. POSimple Django Search Run on Django App Engine?
    primarykey
    data
    text
    <p>In my Django project that aggregates NBA player stats (as a learning project), I've built a simple search view that allows you to search for players by first or last name (or both). It works totally fine on the dev server, but now I want to deploy my site using Google App Engine, and I'm getting errors that I believe are due to GAE's High Replication Datastore.</p> <p>I was under the impression that the <a href="http://www.allbuttonspressed.com/blog/django/2010/09/Get-SQL-features-on-NoSQL-with-django-dbindexer" rel="nofollow">Django-nonrel/dbindexer</a> tools would help alleviate this problem, but so far I've tried implementing them to no avail--when I attempt a search on my site, I get an error log with the message: 'DatabaseError: This query is not supported by the database.'</p> <p>I'm guessing my problem might be that the instructions for these tools are spread across multiple docs written at different points in their development, so it's tricky for me to put them together into one coherent picture. Also, I've looked at the testapp they offer and it seems to be set up somewhat differently than their instructions would suggest. So I'd like to ask two questions: </p> <p>1) Is the view I've coded is even possible to use with GAE and Django-nonrel/dbindexer? Here it is:</p> <pre><code>def search(request): query = request.GET.get('q','') querywords = query.split(' ') lname='' for word in querywords[1:-1]: lname += word+' ' lname += querywords[-1] if query: if len(querywords)&gt;1: qset = ( Q(first_name__iexact=querywords[0]) &amp; Q(last_name__iexact=lname) ) exact_results = Player.objects.filter(qset).distinct() if exact_results != []: result = exact_results qset = ( Q(first_name__icontains=querywords[0])| Q(last_name__icontains=querywords[0])| Q(first_name__icontains=lname)| Q(last_name__icontains=lname) ) results = Player.objects.filter(qset).distinct() results = results.order_by('last_name','first_name') else: qset = ( Q(first_name__icontains=querywords[0]) &amp; Q(last_name__icontains=lname)| Q(first_name__icontains=querywords[0])| Q(last_name__icontains=querywords[0]) ) results = Player.objects.filter(qset).distinct() results = results.order_by('last_name','first_name') result = '' else: qset = ( Q(first_name__icontains=querywords[0])| Q(last_name__icontains=querywords[0]) ) results = Player.objects.filter(qset).distinct() results = results.order_by('last_name','first_name') result = '' else: results = [] result = '' return render(request,'search.html', { 'result':result, 'results': results, 'query': query, 'querywords':querywords }) </code></pre> <p>2) If it is possible to use, and my project in dev is structured as follows, what is the most parsimonious set of steps I can follow to make my search view work properly on GAE?</p> <pre><code>NBA/ __init__.py manage.py settings.py urls.py templates/ (html files) players/ __init__.py admin.py models.py tests.py views.py fixtures/ (some .yaml fixture files) static/ (css, js, and gif files) </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload