Ed Valentine yazmış:
Is there a good way to change the date format in the controller so the
json values are set correctly for the display?
I either need to set the format change in the SQLalchemy select or in
the controller. The json output is going to jgrid for display.
Any suggestions?
Thanks.
My solution is adding a property to the model object to return the
formatted date as string and using that property to return in json
responses.
here is a sample property definition added to the table object in the
model file :
--------------------------
class Sometable(DeclarativeBase):
__tablename__ = 'sometable'
id = Column(Integer, autoincrement=True, primary_key=True)
somedate = Column(Date, index=True, nullable=True, default=None)
""" other fields are deleted """
@property
def somedate_formatted(self):
if self.somedate is None:
s = u''
else:
s = self.somedate.strftime("%d.%m.%Y")
return s
----------------
I do not think this is the best solution, I consider myself as a python
newbie.
--
You received this message because you are subscribed to the Google Groups
"TurboGears" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/turbogears?hl=en.