It gives error: `*AttributeError('str' object has no attribute 'tablename')*
`

The reason is that the field names are in string format not in
db.tablename.fieldname format


On Wed, Jan 27, 2021 at 6:30 PM Jim Steil <ato.st...@gmail.com> wrote:

> What is wrong with using the example you provided?
>
> -Jim
>
>
> On Tue, Jan 26, 2021 at 10:45 PM Muhammad Atif Ayaz <matifa...@gmail.com>
> wrote:
>
>> Thank you Jim, it works.
>>
>> Do you think a way that can help dynamically making a list of all fields
>> of a table and then we can remove specific fields from it.
>> Like the following which produces the required list but in the desired
>> data-type:
>> fields = [fld for fld in db.engagement.fields if fld!='token']
>> grid = SQLFORM.grid(db.engagement, fields=fields)
>>
>>
>> On Tue, Jan 26, 2021 at 9:50 PM Jim S <ato.st...@gmail.com> wrote:
>>
>>> Can you try with the field in the format:
>>>
>>> db.tablename.fieldname
>>>
>>> ex:
>>>
>>> fields = [db.engagement.id, db.engagement.name]
>>>
>>> -Jim
>>>
>>>
>>> On Monday, January 25, 2021 at 11:45:49 PM UTC-6 at wrote:
>>>
>>>> Here is the code:
>>>> `fields=['id', 'name']`
>>>> `grid = SQLFORM.grid(db.engagement, fields=fields)`
>>>>
>>>> Error:
>>>> `AttributeError('str' object has no attribute 'tablename')`
>>>>
>>>>
>>>> --
>>> 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/Ym3zsLYNePg/unsubscribe.
>>> To unsubscribe from this group and all its topics, send an email to
>>> web2py+unsubscr...@googlegroups.com.
>>> To view this discussion on the web visit
>>> https://groups.google.com/d/msgid/web2py/e19daf19-95c7-4e46-88da-74882bd4e51an%40googlegroups.com
>>> <https://groups.google.com/d/msgid/web2py/e19daf19-95c7-4e46-88da-74882bd4e51an%40googlegroups.com?utm_medium=email&utm_source=footer>
>>> .
>>>
>> --
>> 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/Ym3zsLYNePg/unsubscribe.
>> To unsubscribe from this group and all its topics, send an email to
>> web2py+unsubscr...@googlegroups.com.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/web2py/CAFpY7yFSRZMRPY02sHJtxGasp3T%3Dy7sRdqbq58KncYDdDpkXDg%40mail.gmail.com
>> <https://groups.google.com/d/msgid/web2py/CAFpY7yFSRZMRPY02sHJtxGasp3T%3Dy7sRdqbq58KncYDdDpkXDg%40mail.gmail.com?utm_medium=email&utm_source=footer>
>> .
>>
> --
> 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/Ym3zsLYNePg/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> web2py+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/web2py/CAERBpoCjJrCe_3W1Nq%3DZKh8wFc-e8stoHOpMzDwxMHfbFjexKA%40mail.gmail.com
> <https://groups.google.com/d/msgid/web2py/CAERBpoCjJrCe_3W1Nq%3DZKh8wFc-e8stoHOpMzDwxMHfbFjexKA%40mail.gmail.com?utm_medium=email&utm_source=footer>
> .
>

-- 
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 web2py+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/web2py/CAFpY7yHS54wiYKsMDof82z%2BD%2BsS%3DAeC%3D1CtyFa5Wx20guw495A%40mail.gmail.com.

Reply via email to