Error: Object of type datetime is not JSON serializable
See original GitHub issueHello!
This project is great. I’ve run into an issue though. I was trying to run this (unfinished) query:
select m.id, m.pub_name, m.pub_id, m.contents_restricted,
array_agg(s.updated_at) as sub_dates
from main_manuscript m
left join main_submission s on m.id=s.manuscript_id
group by m.id, m.pub_name, m.pub_id, m.contents_restricted
order by m.id
The problem is that django-sql-dashboard errors out because it doesn’t know how to serialize the s.updated_at
DateTime field for working with array_agg
.
As far as I could tell the only way to fix this would be to fork the codebase? Am I missing something? Thanks!
Issue Analytics
- State:
- Created 2 years ago
- Comments:6 (5 by maintainers)
Top Results From Across the Web
How to overcome "datetime.datetime not JSON serializable"?
My quick & dirty JSON dump that eats dates and everything: json.dumps(my_dictionary, indent=4, sort_keys=True, default=str). default is a function applied ...
Read more >TypeError: Object of type datetime is not JSON serializable
The Python TypeError: Object of type datetime is not JSON serializable occurs when we try to convert a `datetime` object to a JSON...
Read more >Object of Type Datetime Is Not Json Serializable in Python
When we get the object of type datetime is not JSON serializable exception in Python, it means that the datetime object cannot be...
Read more >Python Serialize Datetime into JSON
Learn how to solve Object of type datetime is not JSON serializable when you try to convert Python datetime into JSON.
Read more >Object of type datetime is not JSON serializable
Solution 2. Generally, using of json. dumps with a custom converter. By default, it converts everything it doesn't know to a string.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
This is the code causing the error: https://github.com/simonw/django-sql-dashboard/blob/ea3c2bebeb9b4d567991840f8046f18d9d0ffab8/django_sql_dashboard/utils.py#L53-L56
Awesome! Thanks so much 😃