I see they both have notnull=True.

 (and format atribute).

On Saturday, December 14, 2013 9:51:07 PM UTC+2, Anthony wrote:
>
> Are f_item_category and f_item_store reference fields? If so, they only 
> get the default "represent" validator if (a) you do not explicitly specify 
> a "requires" attribute and instead use the default validator, and (b) the 
> referenced table has a "format" attribute. Otherwise, you will need to 
> explicitly define the "represent" attributes.
>
> Anthony
>
> On Saturday, December 14, 2013 2:08:10 PM UTC-5, Avi A wrote:
>>
>> thanks,
>> why I try and use it is because when I use:
>> {{for item in all_items:}}
>> {{=item.created_by}}
>> {{=item.f_item_category}}
>> {{=item.f_item_store}}
>> {{pass}}
>>
>> it renders: (2 items)
>> 1 3 1 1 14 1
>>
>> On Saturday, December 14, 2013 8:42:01 PM UTC+2, Anthony wrote:
>>>
>>> db.t_stores.created_by is a reference field, so by default it gets a 
>>> "represent" attribute if the table to which it refers has a "format" 
>>> attribute. The other fields presumably are not reference fields (nor other 
>>> types of special fields that get default "represent" attributes), so they 
>>> have no "represent" function. Why are you trying to apply "represent" 
>>> functions to those fields anyway? Aren't they just string fields that 
>>> display what you want as is?
>>>
>>> Note, as an alternative, you can do:
>>>
>>> {{for item in all_items.render():}}
>>> {{=item.created_by}}
>>> ...
>>>
>>> The .render() method automatically applies "represent" attributes to all 
>>> fields that have them.
>>>
>>> Anthony
>>>
>>> On Saturday, December 14, 2013 1:02:08 PM UTC-5, Avi A wrote:
>>>>
>>>> Hi,
>>>> I want to display item and use the represent() method to display 
>>>> reference fields.
>>>> def home():
>>>>     all_items = db(db.t_items).select()
>>>>     owner_rep = db.t_stores.created_by
>>>>     store_rep = db.t_stores.f_store_name
>>>>     category_rep = db.t_categories.f_category_name
>>>>     return dict(all_items = all_items, owner_rep = owner_rep, store_rep 
>>>> = store_rep, category_rep = category_rep)
>>>>
>>>> #On the view page :
>>>> {{for item in all_items:}}
>>>> {{=owner_rep.represent(item.created_by)}}
>>>> {{=category_rep.represent(item.f_item_category)}}
>>>> {{=store_rep.represent(item.f_item_store)}}
>>>> {{pass}}
>>>>
>>>>
>>>> While it works for the {{=owner_rep....... line, for any of the other 
>>>> line I try to do the same (those under it) I get the error:
>>>>
>>>> TypeError: 'NoneType' object is not callable.
>>>>
>>>> Thanks.
>>>>
>>>>
>>>>
>>>>

-- 
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.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to