Folks:
I'm stumped over this one.
I have a model:
class QuestionAsked(models.Model):
user = models.ForeignKey(User)
asked = models.ForeignKey(QuestionTable)
date = models.DateTimeField()
choice = models.CharField(max_length=1)
correct = models.BooleanField()
...and when I try to insert a record, the date is always 0000-00-00
00:00:00
I put prints around the .save() to see if the value is getting set
correctly, and it is:
asked = QuestionAsked(user=request.user, asked=q[0],
date=datetime.datetime.now(), choice="", correct=False)
print asked.date # <----
asked.save()
print asked.id # <-----
print asked.date <-----
return render_to_response('question.html', {'question': q[0]})
This prints out: (Note the DateTime field has a value!)
[10/Mar/2009 17:22:23] "POST /blog/new/ HTTP/1.1" 302 0
2009-03-10 17:22:23.855105
7
2009-03-10 17:22:23.855105
[10/Mar/2009 17:22:23] "GET /poller/question/ HTTP/1.1" 200 635
But if I check the database, the DateTime is all zeroes
mysql> select * from poller_questionasked where id=7;
+----+---------+----------+---------------------+--------+---------+
| id | user_id | asked_id | date | choice | correct |
+----+---------+----------+---------------------+--------+---------+
| 7 | 3 | 4 | 0000-00-00 00:00:00 | c | 0 |
+----+---------+----------+---------------------+--------+---------+
1 row in set (0.00 sec)
mysql>
Any ideas on how/why this is happening?
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django users" 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/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---