Monday, September 5, 2011

Re: time part of datetime not saved

dump your code ?! 
BTW, 
You can set auto_now_add = true in the model, which will assign the current datetime, while saving without any code at all.

On Mon, Sep 5, 2011 at 11:54 AM, het.oosten <het.oosten@gmail.com> wrote:
I have a model start = models.DateTimeField()

In my view I create a datetime:
x = datetime.datetime(*(time.strptime(str(component.get('dtstamp')),'%Y
%m%dT%H%M%SZ')[0:6])) .

This return a valid datetime:
>>> x
datetime.datetime(2011, 9, 4, 8, 45, 32)

The problem is that only the date part is saved in the database. The
time is saved as zero's:
>>> db.created
datetime.datetime(2011, 9, 4, 0, 0)

Do i need to convert the date before saving it into the database?

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.




--
Thanks and Regards,
Praveen Krishna R

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

No comments:

Post a Comment