Reputation: 529
I have table in Oracle, which has field of DATE type. Also I have model in Django with DateTimeField. I want to save datetime in Oracle's DATE field, but Django ORM raises such exception:
DatabaseError: ORA-01830: date format picture ends before converting entire input string
I tried to use Django DateField, but it didn't save datetime, only date. How can I save datetime in Oracle using Django (I don't want to use DATETIME field in Oracle because of legacy problems).
My model:
class MyModel(models.Model):
filled_date = models.DateTimeField(db_column='filled_date')
Upvotes: 1
Views: 1709
Reputation: 529
I found the solution for problem. Oracle waits format 'YYYY-MM-DD HH24:MI:SS', but datetime.datetime.now() returns string like this: u'2013-10-18 05:50:44.332577'. The solution:
model.filled_date = datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S')
model.save()
Upvotes: 2