jfinkels/flask-restless — pull request #265 by bildja (2013-11-23 11:22:50+00:00)
Title: String to dates for relations

When updating the related nested models with the date fields, they (the date fields) don't convert to the `datetime` python objects and it raises an exception. For example, we have such models:

```
class Computer(db.Model):
id = db.Column(db.Integer, primary_key=True)
name = db.Column(db.Unicode, unique=True)
purchase_time = db.Column(db.DateTime)
notes = db.relationship('Note')

class Note(db.Model):
id = db.Column(db.Integer, primary_key=True)
text = db.Column(db.Text)
created_at = db.Column(db.DateTime, default=datetime.datetime.now)
computer_id = db.Column(db.Integer, db.ForeignKey('computer.id'))
```

We send such PUT request to /api/computer/18:
```
{
"id":18,
"name":"Galina.",
"notes": [
{
"text":"ew",
"computer_id":18,
"created_at":"2013-11-23T13:18:57"
}
],
"purchase_time":"2013-11-09T14:55:23"
}
```

The `purchase_time` field is being perfectly parsed and converted to the `datetime` python object in the `.patch()` method of view, but the `created_at` field in `notes` raises an exception:
`StatementError: SQLite DateTime type only accepts Python datetime and date objects as input. (original cause: TypeError: SQLite DateTime type only accepts Python datetime and date objects as input.) 'INSERT INTO note (text, created_at, computer_id) VALUES (?, ?, ?)' [{'text': u'test text', 'created_at': u'2013-11-23T13:18:57', 'computer_id': 18}]`