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

  • Home
  • SEARCH
  • 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 7746615
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T10:19:26+00:00 2026-06-01T10:19:26+00:00

I am an absolutely newb to GAE and am trying my first sample application.

  • 0

I am an absolutely newb to GAE and am trying my first sample application.
I have written a simple HTMl form. on clicking submit, the details in the fields need to be saved in the datastore.

My problem is that I am getting datatype exceptions and i have no idea where i am going wrong

import cgi
import datetime
import urllib
import wsgiref.handlers
import os
from google.appengine.ext.webapp import template

from google.appengine.ext import db
from google.appengine.api import users
from google.appengine.ext import webapp
from google.appengine.ext.webapp.util import run_wsgi_app

class Champion(db.Model):
    champion_first_name = db.StringProperty()
    champion_last_name = db.StringProperty()
    champion_email = db.EmailProperty()
    champion_phone_code = db.IntegerProperty()
    champion_phone_number = db.IntegerProperty()
    diabetic_first_name = db.StringProperty()
    diabetic_last_name = db.StringProperty()
    diabetic_age = db.IntegerProperty()
    diabetic_gender = db.StringProperty()
    diabetic_email = db.EmailProperty()
    diabetic_phone_code = db.IntegerProperty()
    diabetic_phone_number = db.IntegerProperty()
    diabetic_city = db.StringProperty()
    diabetic_zipcode = db.IntegerProperty()
    diabetic_since = db.IntegerProperty()
    diabetic_relationship = db.StringProperty()
    checkup_date = db.DateProperty ()
    md_advert_feedback = db.StringProperty()
    timestamp = db.DateTimeProperty(auto_now_add=True)

class MainPage(webapp.RequestHandler):
    def get(self):
        template_values = {}
        path = os.path.join(os.path.dirname(__file__), 'main.html')
        self.response.out.write(template.render(path, template_values))

    def post(self):
        pledge_data = Champion(champion_first_name = cgi.escape(self.request.get('champ_first_name')),
                    champion_last_name = cgi.escape(self.request.get('champ_last_name')),
                    champion_email = cgi.escape(self.request.get('champ_email')),
                    champion_phone_code = cgi.escape(self.request.get('champ_phone_code')),
                    champion_phone_number = cgi.escape(self.request.get('champ_phone_number')),
                    diabetic_first_name = cgi.escape(self.request.get('diab_first_name')),
                    diabetic_last_name = cgi.escape(self.request.get('diab_last_name')),
                    diabetic_age = cgi.escape(self.request.get('diab_age')),
                    diabetic_gender = cgi.escape(self.request.get('diab_gender')),
                    diabetic_email = cgi.escape(self.request.get('diab_email')),
                    diabetic_phone_code = cgi.escape(self.request.get('diab_phone_code')),
                    diabetic_phone_number = cgi.escape(self.request.get('diab_phone_number')),
                    diabetic_city = cgi.escape(self.request.get('diab_city')),
                    diabetic_zipcode = cgi.escape(self.request.get('diab_zip')))
                    # diabetic_since = cgi.escape(int(self.request.get('diab_since'))))
                    # diabetic_relationship = cgi.escape(self.request.get('diab_relationship')),
                    # md_advert_feedback = cgi.escape(self.request.get('md_ad_feedback'))
                    # checkup_date = cgi.escape(self.request.get('checkup_date')),
                    # )

        pledge_data.put()


application = webapp.WSGIApplication([
    ('/', MainPage),
], debug=True)


def main():
  run_wsgi_app(application)


if __name__ == '__main__':
  main()

The error i am getting is

Traceback (most recent call last):
  File "C:\Program Files (x86)\Google\google_appengine\google\appengine\ext\webapp\_webapp25.py", line 703, in __call__
    handler.post(*groups)
  File "C:\Users\Rishav\Documents\Google App Engine\helloworld\main.py", line 54, in post
    diabetic_zipcode = cgi.escape(self.request.get('diab_zip')))
  File "C:\Program Files (x86)\Google\google_appengine\google\appengine\ext\db\__init__.py", line 945, in __init__
    prop.__set__(self, value)
  File "C:\Program Files (x86)\Google\google_appengine\google\appengine\ext\db\__init__.py", line 599, in __set__
    value = self.validate(value)
  File "C:\Program Files (x86)\Google\google_appengine\google\appengine\ext\db\__init__.py", line 3141, in validate
    % (self.name, type(value).__name__))
BadValueError: Property champion_phone_number must be an int or long, not a unicode

I am absolutely certain the answer is gonna make me faceplam, but i am just not getting it now. I believe I have put in the correct db model.
also, it makes no difference if I actually input any data in the webform form field or not. I get the same error even when i leave the fields null and then hit submit.

EDIT:
OP here.
in case anyone is interested in what i did;
once I converted all required field data to int, i found another error.
I would get valueerror eception if any of my fields had null value.
Now i want to leave all my data entry validation on the client side.
so i changed my code to;

def post(self):
    pledge_data = Champion()
    try:
        pledge_data.champion_first_name = cgi.escape(self.request.get('champ_first_name'))
        pledge_data.champion_last_name = cgi.escape(self.request.get('champ_last_name'))
        pledge_data.champion_email = cgi.escape(self.request.get('champ_email'))
        pledge_data.champion_phone_code = int(cgi.escape(self.request.get('champ_phone_code')))
        pledge_data.champion_phone_number = int(cgi.escape(self.request.get('champ_phone_number')))
        pledge_data.diabetic_first_name = cgi.escape(self.request.get('diab_first_name'))
        pledge_data.diabetic_last_name = cgi.escape(self.request.get('diab_last_name'))
        pledge_data.diabetic_age = int(cgi.escape(self.request.get('diab_age')))
        pledge_data.diabetic_gender = cgi.escape(self.request.get('diab_gender'))
        pledge_data.diabetic_email = cgi.escape(self.request.get('diab_email'))
        pledge_data.diabetic_phone_code = int(cgi.escape(self.request.get('diab_phone_code')))
        pledge_data.diabetic_phone_number = int(cgi.escape(self.request.get('diab_phone_number')))
        pledge_data.diabetic_city = cgi.escape(self.request.get('diab_city'))
        pledge_data.diabetic_zipcode = int(cgi.escape(self.request.get('diab_zip')))
        pledge_data.diabetic_since = int(cgi.escape(self.request.get('diab_since')))
                # diabetic_relationship = cgi.escape(self.request.get('diab_relationship')),
                # md_advert_feedback = cgi.escape(self.request.get('md_ad_feedback'))
                # checkup_date = cgi.escape(self.request.get('checkup_date')),
                # )
    except ValueError:
        pass

    pledge_data.put()
  • 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-01T10:19:27+00:00Added an answer on June 1, 2026 at 10:19 am

    The quick fix is to explicitly cast, e.g.:

    ...
    champion_phone_number = int(cgi.escape(self.request.get('champ_phone_number'))),
    ...
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have absolutely no knowledge in Regex whatsoever. Basically what I'm trying to do
this is driving me absolutely crazy. I'm trying to deploy an application to one
I am absolutely new to the Android platform and have been building an application
I have an absolutely positioned div containing several children, one of which is a
I'm a jQuery newb and I've been trying to create a custom slideshow widget
I have an absolutely positioned bar at the top of my website that is
I have an absolutely positioned div containing several children, one of which is a
I have an absolutely positioned element at the bottom of a container element. The
I am a FOP newb. I am trying to show text on top of
I absolutely love what HAML and SASS have done for my design habits. I

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.