I'm following the official example on how to use Django forms from
http://code.google.com/appengine/articles/djangoforms.html

Want to define st:state - AK:Alaska, AL=Alabama, etc. so that people
can use "Alaska" instead of "AK"

I want to store both st and state in the table for entries so I don't
have to do a lookup later.

So I want to present a pull-down with the list of states.  On submit,
look up the abbreviation for Alaska and store them both.

I want to use the abbreviation because /state/dc looks like less cause
for trouble down the road than /state/district%20of%20columbia

>From the example, I don't understand how I can access the form
variables.   Seemed like StatesForm.state would work but it doesn't.

class US_States(db.Model):
    st = db.StringProperty(required=True,multiline=False)
    state = db.StringProperty(required=True,multiline=False)

class US_Info(db.Model):
    st = db.StringProperty(required=True,multiline=False)
    state = db.StringProperty(required=True,multiline=False)
    info = db.TextProperty

class US_InfoForm(djangoforms.ModelForm):
    class Meta:
        model = US_Info


class AddInfo(webapp.RequestHandler):
    def get(self):
        form = US_InfoForm()
        # original had self.response.out.write( US_InfoForm() )
        self.response.out.write('<html><body>' )
        self.response.out.write('<br> <a href="/">Home</a>')
        self.response.out.write(' > <a href="/states.html">States</
a><br>' )
        self.response.out.write('<form method="POST" '
                    'action="/add_plate/">' )
        self.response.out.write('<table>')
        self.response.out.write(form )
        self.response.out.write('</table>'
                    '<input type="submit">'
                    '</form></body></html>')
        query = db.GqlQuery("SELECT * FROM US_States WHERE state = :
1", form.state)
        # doesn't work
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Google App Engine" group.
To post to this group, send email to google-appengine@googlegroups.com
To unsubscribe from this group, send email to 
google-appengine+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/google-appengine?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to