How can I get value from my extra_fields?

52 views
Skip to first unread message

Константин Комков

unread,
Aug 1, 2019, 3:53:34 AM8/1/19
to web2py-users
I added field 'language' im my auth_user table in database. My file db.py contain:
auth = Auth(db, host_names=configuration.get('host.names'))

auth.settings.extra_fields['auth_user']= [Field('language')]

auth
.define_tables(username=False, signature=False)
How can I get value of language for current login user?
myStr = ''
for a in auth.user:
    myStr
+= a+': '+str(auth.user.get(a))+'<br>'
myStr >>>
id: 1
first_name: Константин
last_name: Комков
registration_key: 
reset_password_key: 
registration_id:
test = str(auth.settings.extra_fields.get('auth_user')[0])
test >>>
auth_user.language

Val K

unread,
Aug 1, 2019, 2:21:32 PM8/1/19
to web2py-users
Try db.auth_user(auth.user_id).language

Константин Комков

unread,
Aug 1, 2019, 2:32:22 PM8/1/19
to web...@googlegroups.com
It's query to database I thought that I can get it from session like auth.user. Thank you for answer!

чт, 1 авг. 2019 г., 21:21 Val K <valq...@gmail.com>:
Try db.auth_user(auth.user_id).language

--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
---
You received this message because you are subscribed to a topic in the Google Groups "web2py-users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/web2py/7cgw04bcOiA/unsubscribe.
To unsubscribe from this group and all its topics, send an email to web2py+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/web2py/2b60f329-b68f-4cc5-b5a2-fc9f23483d74%40googlegroups.com.

Val K

unread,
Aug 1, 2019, 3:06:53 PM8/1/19
to web2py-users
Should be stored in the session too, did you try to logout/login?

Константин Комков

unread,
Aug 1, 2019, 4:16:13 PM8/1/19
to web...@googlegroups.com
I did'n try to login/logout. I do it and all work! Thank you!
Reply all
Reply to author
Forward
0 new messages