Please show the full traceback.
On Tuesday, June 5, 2018 at 9:52:52 AM UTC-4, kakella wrote:
>
> Need some insights into the below issue. The functionality is working
> correctly in the SQLForm.grid but doesn't work when returning data as json
> under certain circumstances as mentioned below.
>
> When using the rows.render and passing multiple fields as argument there
> is an
> exception "web2py.app.projectmgmt - WARNING - 'NoneType' object has no
> attribute 'first_name'"
>
> the exception is happening on the db.environment.onboarding_resource. When
> the represent for the Field is removed in the model it works as expected by
> returning the username correctly. It is not working when trying to return
> the first and last names.
>
> def getenvironments():
> rows = list()
> try:
> rows = db(db.environment).select()
> #Below works
> print rows.render(0, fields=[db.environment.onboarding_resource])
> # Below throws an exception ( 'NoneType' object has no attribute
> 'first_name')
> print rows.render(0,
> fields=[db.environment.onboarding_resource,db.environment.request])
> except Exception as e:
> logger.warn(str(e))
> return response.json(rows)
>
> Model definition
> --------------------------------------------
>
> db.define_table('environment',
> Field('request', db.request,
> requires=IS_EMPTY_OR(IS_IN_DB(db, 'request.id','%(requested_item)s
> %(alt_CI_ID)s'))),
> Field('onboarding_resource', db.auth_user,
> represent = lambda id, row: '%s %s'
> %(db.auth_user(id).first_name,db.auth_user(id).last_name),
> requires=IS_EMPTY_OR(IS_IN_DB(db,
> 'auth_user.id','%(first_name)s
> %(last_name)s'))),
> Field('delivered_date', type='date'),
> Field('missed_reason', db.missed_reason,
> requires=IS_EMPTY_OR(IS_IN_DB(db,'missed_reason.id
> ','%(reason_code)s'))))
>
>
>
>
--
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 the Google Groups
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.