Hello How I should define format if my controller looks like: def view(): form = SQLFORM(db.book) records = db(db.book.id>0).select(orderby='date') if form.accepts(request.vars): redirect(URL(r=request,f='view')) if form.errors: response.flash="error" return dict(form=form,records=records)
and in view: {{for record in records:}} <tr id="record-{{=record.id}}" class="record"> <td>{{=record.nn}}</td> <td>{{=record.name}}</td> <td>{{=record.num}}</td> <td>{{=record.date}}</td> <td>{{=record.operation}}</td> <td>{{=record.inc_sale}}</td> <td>{{=record.inc_copy}}</td> <td>{{=record.inc_other}}</td> <td>{{=int(record.inc_sale)+int(record.inc_copy)+int (record.inc_other)}}</td> <td><a href='{{=URL(r=request,f="d",args=[record.id])}}' class="delete" >X</a> </tr> {{pass}} in input field date looks like I defined it (%d.%m.%Y), but after insertion, in view, it looks like defaul (%Y-%m-%d) On 23 май, 09:47, annet.verm...@gmail.com wrote: > Horst, > > Model: > > T.force('en-de') ## en-de is a language file you'll create below > > In the table definition: > > SQLField('fieldname', type='date') > > ... a validator on this field which reads like: > > db.tablename.fieldname.requires=IS_NULL_OR(IS_DATE(str(T('%Y-%m- > %d')))) > > Languages: > > ... create a language file e.g. en-de.py and edit the dates: > > Original Translation > %Y-%m-%d %d-%m-%Y > %Y-%m-%d %H:%M:%S %d-%m-%Y %H:%M:%S > > Click update. > > Views: > > ... to use the date in a view: > > {{=db.tablename.fieldname.formatter(tablename.fieldname)}} > > If you use form_factory to create a custom form, the code in the > controller should read: > > SQLField('fieldname',type='date',requires=IS_DATE(str(T('%Y-%m- > %d')))) > > I hope I did not leave anything out, if so, let me know. > > Kind regards, > Annet. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "web2py-users" group. To post to this group, send email to web2py@googlegroups.com To unsubscribe from this group, send email to web2py+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/web2py?hl=en -~----------~----~----~----~------~----~------~--~---