Datastore query outputting for Django form instance

Posted by Jelle on Stack Overflow See other posts from Stack Overflow or by Jelle
Published on 2010-05-06T15:11:40Z Indexed on 2010/05/06 15:58 UTC
Read the original article Hit count: 267

Hello!

I'm using google appengine and Django. I'm using de djangoforms module and wanted to specify the form instance with the information that comes from the query below.

    userquery = db.GqlQuery("SELECT * FROM User WHERE googleaccount = :1", users.get_current_user())

    form = forms.AccountForm(data=request.POST or None,instance=?????)

I've found a snippet in a sample app that does this trick, but I can't modify it to work with the query I need.

    gift = User.get(db.Key.from_path(User.kind(), int(gift_id)))
    if gift is None:
         return http.HttpResponseNotFound('No gift exists with that key (%r)' %
                                   gift_id)
    form = RegisterForm(data=request.POST or None, instance=gift)

Could anyone help me?

© Stack Overflow or respective owner

Related posts about google-app-engine

Related posts about django