How do I check for Existence of a Record in GAE
I am trying to create a simple view in Django & GAE, which will check if the user has a profile entity and prints a different message for each case. I have the program below, but somehow GAE always seem to return a object. My program is below
<pre>
import datetime
from django.http import HttpResponse, HttpResponseRedirect
from google.appengine.api import users
from google.appengine.ext import db
from models import Profile
import logging
#from accounts.views import profile

# Create your views here.
def login_view(request):
    user = users.get_current_user()
    profile = db.GqlQuery("SELECT * FROM Profile WHERE account = :1",
                            users.get_current_user())
    logging.info(profile)
    logging.info(user)
    if profile:
        return HttpResponse("Congratulations Your profile is already created.")
    else:
        return HttpResponse("Sorry Your profile is NOT created.")
</pre>

My model object is Profile defined as follows:
<pre>
class Profile(db.Model):
    first_name = db.StringProperty()
    last_name = db.StringProperty()
    gender = db.StringProperty(choices=set(["Male", "Female"]))
    account = db.UserProperty(required = True)
    friends = db.ListProperty(item_type=users.User)
    last_login = db.DateTimeProperty(required=True)
</pre>

Thanks for the help.
How do I check for Existence of a Record in GAE
===

I am trying to create a simple view in Django & GAE, which will check if the user has a profile entity and prints a different message for each case. I have the program below, but somehow GAE always seem to return a object. My program is below
<pre>
import datetime
from django.http import HttpResponse, HttpResponseRedirect
from google.appengine.api import users
from google.appengine.ext import db
from models import Profile
import logging
#from accounts.views import profile

# Create your views here.
def login_view(request):
    user = users.get_current_user()
    profile = db.GqlQuery("SELECT * FROM Profile WHERE account = :1",
                            users.get_current_user())
    logging.info(profile)
    logging.info(user)
    if profile:
        return HttpResponse("Congratulations Your profile is already created.")
    else:
        return HttpResponse("Sorry Your profile is NOT created.")
</pre>

My model object is Profile defined as follows:
<pre>
class Profile(db.Model):
    first_name = db.StringProperty()
    last_name = db.StringProperty()
    gender = db.StringProperty(choices=set(["Male", "Female"]))
    account = db.UserProperty(required = True)
    friends = db.ListProperty(item_type=users.User)
    last_login = db.DateTimeProperty(required=True)
</pre>

Thanks for the help.