Hi, I'm pretty new to app engine, and I'm trying to set a bit of text into the app engine database for the first time.
Here's my code:
def setVenueIntroText(text):
venue_obj = db.GqlQuery("SELECT * FROM Venue").get()
venue_obj.intro_text = text # Works if I comment out
db.put(venue_obj) # These two lines
This throws some sort of exception - I can't tell what it is though because of my django 1.02 setup.
Ok, I gave the code in the answer below a go, and it worked after deleting my datastores, but I'm still not satisfied.
Here's an update:
I've modified my code to something that looks like it makes sense to me. The getVenueIntroText doesn't complain when I call it - I haven't got any items in the database btw.
When I call setVenueIntroText, it doesn't like what I'm doing for some reason - if someone knows the reason why, I'd really like to know :)
Here's my latest attempt:
def getVenueIntroText():
venue_info = ""
venue_obj = db.GqlQuery("SELECT * FROM Venue").get()
if venue_obj is not None:
venue_info = venue_obj.intro_text
return venue_info
def setVenueIntroText(text):
venue_obj = db.GqlQuery("SELECT * FROM Venue").get()
if venue_obj is None:
venue_obj = Venue(intro_text = text)
else:
venue_obj.intro_text = text
db.put(venue_obj)