My confidence is high that I am just being an idiot, but I've now
spent several hours on this without luck. I have zero experience with
either Python, Django or App-Engine - just trying to get something
very simple started so I can learn.
I have successfully bulk uploaded about 20 entities of type Shop into
the datastore. I can see them and query them via the browser based
application Data Viewer.
I cannot figure out how to get access to them from my application.
in model.py:
from google.appengine.ext import db
class Shop(db.Model) :
name = db.StringProperty(required=True)
description = db.TextProperty()
location = db.GeoPtProperty()
address1 = db.PostalAddressProperty()
address2 = db.StringProperty()
address3 = db.StringProperty()
city = db.StringProperty()
state = db.StringProperty()
zip = db.IntegerProperty()
address = db.PostalAddressProperty()
phone = db.PhoneNumberProperty()
myRating = db.RatingProperty(choices=[0,1,2,3], default=0)
userRating = db.RatingProperty()
url = db.LinkProperty()
email = db.EmailProperty()
uploaded = db.DateTimeProperty()
def __unicode__(self):
in view.py
from google.appengine.ext import db
from myapp.models import Shop
from ragendja.dbutils import get_object_list, get_object
from django.http import HttpResponse
from django.views.generic.list_detail import object_list,
object_detail
from ragendja.template import render_to_response
from django.template import Context, loader
def get_shop_by_state(request, state):
# ShopList = get_object_list(Shop, 'state =', state)
# ShopList = Shop.all()
# ShopList = db.GqlQuery("SELECT * FROM Shop WHERE state = 'FL'")
item = get_object(Shop, id=2005)
# query = Shop.gql("WHERE state = 'FL'")
# results = query.fetch(10)
# t = loader.get_template('shops.html')
# c = Context({
# 'NewShopList': ShopList,
# })
# return HttpResponse(t.render(c))
return HttpResponse("Got State = " + item.state)
# return object_list(request, results, paginate_by=10)
You can see that I've tried several different approaches (Shop.all(),
db.GqlQuery(), get_object()) - none of them work.
Eventually, I want to be able to query the datastore (for example, to
find all of the shops in a given state), and then output that list via
a template. For now, I'd be happy if someone can tell me why the code
above, which seems like the most simple possible case, doesn't work.
Thanks!
--
You received this message because you are subscribed to the Google Groups
"app-engine-patch" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/app-engine-patch?hl=en.