distinct-query_type crashes with TypeError if fieldname is one that contains datestamps

Created by: yytosi

To reproduce;:

POST /query/studies?query_type=distinct {"fieldname":"_metadata"}

Crashes with TypeError: datetime.datetime ... is not JSON serializable