Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8286517
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T11:47:42+00:00 2026-06-08T11:47:42+00:00

In my Django project that aggregates NBA player stats (as a learning project), I’ve

  • 0

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.

I was under the impression that the Django-nonrel/dbindexer 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.’

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:

1) Is the view I’ve coded is even possible to use with GAE and Django-nonrel/dbindexer? Here it is:

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)>1:
                        qset = (
                                Q(first_name__iexact=querywords[0]) &
                                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]) &
                                        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
        })

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?

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)
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T11:47:44+00:00Added an answer on June 8, 2026 at 11:47 am

    Ok, so after fiddling around with different kinds of queries using “python manage.py remote shell”, I’ve come to the following conclusions:

    1) As @dragonx mentioned, Q objects with “OR” are not supported.

    2) However, Q objects with “&” definitely are.

    3) The problem with my search view code, other than the “OR” queries, was the addition of “distinct()” in my “Player.objects.filter()” call. Apparently the HRD doesn’t support “distinct()”, and this was responsible for the cryptic

    “DatabaseError: This query is not supported by the database”

    message. By contrast, attempting to use a Q object with “OR” gives a much more helpful

    “DatabaseError: Only AND filters are supported”

    Now that I’ve removed the “distinct()” bit from my code (and any “OR”-containing Q objects), the search works fine.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a django project that uses views from an external app. The view
I'm building a Django project that needs search functionality, and until there's a django.contrib.search
I have a view in my django project that fires off a celery task.
I have a django project that I have been working on as a solo
I have a django project that runs on a Linux server, and I've been
I've started a django project that will include an analytics app. I want that
I'm working on a small django project that will be deployed in a servlet
So herein lies my question. Django project that was originally developed several years ago
I'm a Beginner, trying to build a django project that runs on Google App
I am new webservers...and... I am working on a django project that is ready

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.