Webapp2-Sample-Applications icon indicating copy to clipboard operation
Webapp2-Sample-Applications copied to clipboard

Add other fields to datastore

Open coto opened this issue 13 years ago • 2 comments

Thanks for this example. Works perfectly, but I can't add another field to the datastore (User entity), for example email. Thanks in advance

coto avatar Jan 25 '12 04:01 coto

You can go two ways about this. Either you create a new model that holds the additional fields like email, address and such. With a auth_key field. And use this when you need that information. Use mainly use this approach due that I find that I usually need this information quite rarely (for like profile pages and such).

The other way is to inherit from webapp2_extras.appengine.auth.models.User and add you own fields. And then change in webapp2 config (http://webapp-improved.appspot.com/api/webapp2_extras/config.html) to use you new model as auth.user_model.

Something like:

my_config['webapp2_extras.auth'] = { 'user_model': 'mymodule.myusermodel', }

app = webapp2.WSGIApplication(routes=[ webapp2.Route('/', name='home', handler=MyHandler) ]) app.config = webapp2_config.Config(my_config)

fredrikbonander avatar Jan 25 '12 10:01 fredrikbonander

I'll try with the first one. BTW the second option doesn't work by defining a user_model, but you can add directly as params to create_user method

Thanks

coto avatar Jan 26 '12 03:01 coto