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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T01:30:44+00:00 2026-05-26T01:30:44+00:00

I have a form where a user logs in with a google account and

  • 0

I have a form where a user logs in with a google account and then makes or updates their profile in google app engine. I want to use the form field that contains their email address (which is automatically filled in with their user info from google) as the new entry’s key. This way I can easily update the entries since as long as they have the same email they will be the same entry. Here is my form model and my page post and get methods, how can I modify them to set the key?

class Athlete(db.Model):                                         
    #fields to be added to the form
    norse_key = db.UserProperty()
    key_name = norse_key
    first_name = db.StringProperty()
    last_name = db.StringProperty()
    school_class = db.StringProperty()
    sex = db.StringProperty()
    home_address = db.StringProperty()
    city = db.StringProperty()
    state = db.StringProperty()
    zip = db.IntegerProperty()
    residence = db.StringProperty()
    SPO = db.IntegerProperty()
    cell = db.IntegerProperty
    sport_1 = db.StringProperty()
    sport_2 = db.StringProperty()
    sport_3 = db.StringProperty()

class AthleteForm(djangoforms.ModelForm):
    class Meta():
        model = Athlete()
class AthleteFormPage(webapp.RequestHandler):

    def get(self):
        user = users.get_current_user()
        self.response.out.write((user))
        query = db.GqlQuery("SELECT * FROM Athlete WHERE norse_key = :1", user)
        item = None
        for item in query:
            self.response.out.write("%s,%s<br>" % (item.norse_key,item.first_name))    
        self.response.out.write('<div style="float:right"><a href="%s">Log Out</a> </div >'% (users.create_logout_url("/")))

        self.response.out.write('<html> <body> <a href="/">Submit A Treatment Log</a>  <form method="POST" action="/athleteformpage.html"> <table>')
        if item != None:
            self.response.out.write(AthleteForm(initial={'norse_key':item.norse_key,'first_name':item.first_name}))
        else:
            self.response.out.write(AthleteForm(initial={'norse_key':user}))
        self.response.out.write('</table> <input type="submit"> </form> </body> </html>')


    def post(self):
        data = AthleteForm(data=self.request.POST)
        if data.is_valid():
            # Save the data, and redirect to the view page
            entity = data.save(commit=False)
            entity.added_by = users.get_current_user()
            entity.put()
            self.redirect('/athletes.html')
        else:
            # Reprint the form
            self.response.out.write('<html><body> <form method="POST" action="/athleteformpage.html"> <table>')
            self.response.out.write(data)
            self.response.out.write('</table> <input type="submit"> </form></body></html>')
  • 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-26T01:30:44+00:00Added an answer on May 26, 2026 at 1:30 am

    Every entity in GAE datastore has a key, the key can be an id or string.
    When creating an entity you can specify which value the key will have using the key_name atribute. for example:

    Athlete.get_or_insert(key_name=name, ....)
    

    You can remove the key_name that you put in your model and use the one that comes “out of the box”

    to query for an entity using a key_name use Athlete.get_by_key_name(name).
    Due notice that key is case sensitive so you probbely need to make it canonical (by lower casing it and also probably url decoding it)

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

Sidebar

Related Questions

I have a form a user can enter their name, then it will add
I have a user form that is working perfectly. The page makes use of
in my application i have an form where user enter their username first .
I have a form for a 'user profile' with the following fields: <form> First
I have a form, user logs in and another form is generated. User submits
I have a login form in my app. I want to display the message
I have form with user defined filters ( combobox with column names, combobox with
I have form where user submits field. Field can have letters, numbers, and punctuation.
i have form with user data to input and javascript ajax to send information
If I have form where user can upload files via Ajax (and upload is

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.