New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Error when jsonify query result #47
Comments
This is because
And |
I wrote my jsonify method as:
|
Add a |
How abount Model.jsonify() ? |
Nah, that would normally be a application-specific behavior, and GINO cannot jsonify all types of columns in a way that is acceptable for all scenarios, |
You are right , Model.to_dict() is good! |
|
how about implement |
My new jsonify_model method changed to:
It seems that asyncpg.Record can get data by .items() (it implements iter?) |
@qdzzyb2014 the thing is, |
@jonahfang if isinstance(rec, db.Model):
d = {}
for k, v in rec.to_dict().items():
if isinstance(v, datetime.datetime):
d[fld] = v.strftime('YOUR_FORMAT_HERE')
else:
d[fld] = v |
The following code is a bit ugly:
I have to got 'db' first? |
Well |
Can I write as:
|
No you cannot. |
code:
Error:
The text was updated successfully, but these errors were encountered: