Hi, I am trying to solve the problem, but I am confused by the key. Should
anybody help me to check these code?

I want to update a reference property, I want to change the shop from shop1
to shop2 for custom. I am not sure which way is right:

custom.shop = shop2
custom.put()

or
custom.shop = shop2.key()
custom.put()

I tried these two ways, but not work.

Thanks.




On Sun, Nov 21, 2010 at 3:13 PM, Haulyn R. Jason <[email protected]>wrote:

> Hi,
>
> I am writing something code to create a model, and then update it. I have a
> referenced property, it works well on create function, but it does not work
> in update function. The code is simple as follow:
>
>         r = Information.get(self.params.get('id'))
>         r.shop = Shop.get(self.params.get('shop'))
>         for prop in Information.properties():
>              if prop in self.params:
>                 if prop is 'end_date':
>                     r.end_date =
> datetime.strptime(self.params.get('end_date',None),'%Y/%m/%d')
>                  else:
>                     setattr(r, prop, self.params.get(prop))
>         r.save()
>         self.redirect('/information/show/%s' % (r.key()))
>
> Other properties are updated, but I can not update r.shop, I just tried to
> assign shop2 instead of shop1 for my Information model.
>
> Are there something I missed?
>
>
>  Thanks!
>
> slackdot.com
>
> Location:Room 807,QiLuRuanJianDaSha Qilu Software Park
>         No. 1 Shunhua Rd High-Tech Development Zone
>         Jinan, China 250101
> Website: http://slackdot.com
> Mobile: +86 15854103759
>
> Haulyn Jason
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Google App Engine" 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/google-appengine?hl=en.

Reply via email to