model_to_dict is a function in the "playhouse" extension, which automagically converts a model into a Python dictionary. In other words; you can easily convert data from complex SQL queries straight to JSON.