Em Quarta 26 Abril 2006 08:06, DaddyCOOL escreveu:
> hi

Hi "Daddy".

> i just started with turbogears and have a really begginers question
>
> have this user remove/edit/add application that was working just fine
> until i inserted DateTimeCol field in the database for users to see
> when the user was created or edited. Now I have a problem how to save
> date in the database. Should i pass this value from my form or just add
> it when i save user ? And how do i get this current date to get stored
> in the right format

It depends on how you get the date.  If it is an input field in your form, 
then using the CalendarDateTimePicker seems to be the easiest thing, since it 
will already convert the input to the right format for you.

If you're doing it inside your code, you can set this in your create/update 
methods, inside your model and in your database.  Doing it inside your 
create/update methods will require that you replicate this code everywhere 
you need to create/update records.  Doing it in your model will concentrate 
this only there.

If you're sharing this database with other applications written in other 
languages, then you definitely want to have it as a trigger in your database 
and you won't have to worry with this anywhere in any of your applications.

How to do it?  To get the current date and time:

>>> import datetime
>>> datetime.datetime.now()
datetime.datetime(2006, 4, 26, 14, 36, 9, 119913)
>>> datetime.date.today()
datetime.date(2006, 4, 26)

So, assigning the output of "now()" to a variable and using it to 
insert/update data in your code should do the trick,

> Again I am a noobie in turbogears :)

That's no problem at all ;-)

-- 
Jorge Godoy      <[EMAIL PROTECTED]>


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

Reply via email to