Actually unless I'm missing something I don't think using a computed field 
will work for the create_on field because this seems to modify the field 
any time you update the record.  However it does work for the modified_on 
field.  
 

On Thursday, October 24, 2013 2:30:44 AM UTC-4, User wrote:

> The discrepancy between form generation time and database insertion time 
> is mostly an annoyance when creating new records in appadmin.  
>  
> However, doing it this way I notice the modified time field will not get 
> updated in appadmin because it will already have a value from when the 
> record was originally inserted.  (I've decided on insertion that the 
> modified time will equal the creation time. I realize an alternative option 
> is to keep the modified field null until the record is actually modified, 
> but I prefer my way) Thus, even though I have the following in my models.py
>  
> standard_fields.modified_on.update = request.now
>  
> it will not make a difference in appadmin so it seems like using compute 
> may be the best option
>  
>
> On Saturday, October 5, 2013 9:06:53 PM UTC-4, Anthony wrote:
>
>> On Saturday, October 5, 2013 8:04:54 PM UTC-4, User wrote:
>>
>>> I do have writable=False and I understand that will work for normal 
>>> forms, but it still shows up in appadmin
>>>
>>
>> Yes, appadmin ignores the writable attribute. Is it really important to 
>> distinguish between the time the form is loaded and the time of the insert? 
>> If so, something like this might work (not tested):
>>
>> standard_fields = db.Table(db, 'standard_fields',
>>     Field('created_on', 'datetime', default=request.now))
>> if request.controller == 'appadmin':
>>     standard_fields.created_on.compute = lambda row: request.now
>>
>> I believe appadmin will not show a computed field, so the above should 
>> compute the value at time of insert.
>>
>> Anthony
>>
>

-- 
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