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 6845999
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T00:34:10+00:00 2026-05-27T00:34:10+00:00

I have been struggling with a problem in Google App Engine and Django and

  • 0

I have been struggling with a problem in Google App Engine and Django and have not been able to locate the solution (despite finding similar problems).

Let me set the scene a bit. I have the following three entities:

Contributor:
    user = db.UserProperty()

Question:
    contributor = db.ReferenceProperty(Contributor, collection_name='questions')
    text = db.TextProperty()

Rating:
    contributor = db.ReferenceProperty(Contributor, collection_name='question_ratings')
    question = db.ReferenceProperty(Question, collection_name='ratings')
    rating = db.IntegerProperty(choices=set([1,2,3,4,5]))

In my Django template (below), my general requirements are to display (1) each question, (2) the contributor of the question, and (3) whether or not a question has been rated by the current user.

My problem lies with the third requirement. I have not been able to figure out how to determine whether or not a Question has a Rating for the Contributor associated with current User (i.e., the Contributor with user property users.get_current_user()). How could I accomplish this?

If such a Rating entity exists, a message will be displayed similar to “You have already rated this question.” Otherwise, if no such Rating exists, options to rate the question will be displayed. Here’s my Django template for the first two requirements (and a comment outlining the third).

{% for question in questions %}
    <h1>{{ question.text }}</h1>
    <h2>{{ question.contributor.user.nickname() }}</h2>

    {% comment %}
    if no Rating exists for Question and Contributor:
        <h3>Rating: 1 2 3 4 5</h3>
    else:
        <h3>You have already rated this question.</h3>
    {% endcomment %}
{% endfor %}

Here’s the Python handler script for Google App Engine:

questions = Question.all()

ratings = Rating.all()
ratings.filter('contributor = ', profile)

template_values = {
    'contributor': contributor,
    'questions': questions
}

path = os.path.join(os.path.dirname(__file__), "questions.html")
rendered_text = template.render(path, template_values)
self.response.out.write(rendered_text)
  • 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-05-27T00:34:11+00:00Added an answer on May 27, 2026 at 12:34 am

    The best way to do this is to do the processing in your Python code, and pass in a list of dicts that contain just the relevant information to your Django template. This also means you can take advantage of hacks like reference property prefetching to minimize the number of RPCs you have to do.

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

Sidebar

Related Questions

I have been struggling with a nasty ANR problem with my app, which loads
I've been struggling with Zend_Navigation all weekend, and now I have another problem, which
I have been struggling with this problem for a few days now and I
I have been struggling with a problem for a while and so far have
I have been struggling with a unit testing problem on Android for a while
I have been struggling with this seeminly easy problem for 48 hours, and I
I have been struggling a while with this problem and read a lot but
I have been struggling with a problem that only happens when the database has
I have been struggling with a problem trying to get PLJava to work on
I have been struggling with a problem for a couple of days now with

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.