Skip to content Skip to sidebar Skip to footer

How To Search A Model By Date With Flask-restless

According to the documentation, a search query should look like: GET /api/person?q={'filters':[{'name':'age','op':'ge','val':10}]} How do I compare a date? I tried: GET /api/pers

Solution 1:

Davidism is absolutely right, I shouldn't have said JSON datetime-- JSON doesn't itself have a way of representing a date/datetime format— it's on the sender/reciever ends of the communication to recognise "Hey, I'm expecting a date here, this looks like a date, I'll try and treat it like one".

Generally, most people use ISO 8601 as their datetime representations in JSON (2014-10-23T18:25:43.511Z), and Flask-Restless seems to use dateutil.parse to parse some incoming values back into datetime fields-- but oddly, not GET ones.

So it looks as though the string representing your datetime value needs to match what your database expects-- which on average is going to be an ISO 8601 format.

Post a Comment for "How To Search A Model By Date With Flask-restless"