Google App Engine: 404 Resource Not Found
I am trying to build a basic blog model using Google App Engine in Python. However, something's wrong with my code I suppose, and I am getting a 404 error when I try to display all
Solution 1:
When you create your post, you're giving it a parent (not sure why). But when you get it, you do so by the ID only, and don't take into account the parent ID. In the datastore, a key is actually a path consisting of all the parent kinds and IDs/names and then those of the current entity, and to get an object you need to pass the full path.
Possible solutions here:
- Drop the parent key, since it isn't doing anything here as you're always setting it to the same value;
- Use it when you get the object:
Blogger.get_by_id(post_id, parent=parent_key())
- obviously this only works if the parent is always the same; - Use the full stringified key in the path, rather than just the ID, and do
Blogger.get(key)
- you'll also need to change the route regex to accept alphanumeric chars, eg'/blog/(\w+)'
, and change the redirect to'/blog/%s' % a.key()
.
Post a Comment for "Google App Engine: 404 Resource Not Found"