I have set up an API using the Flask-Peewee API library:
class ActivityResource(RestResource):
exclude = ('id', 'course')
class CourseResource(RestResource):
exclude = ('id')
class SessionResource(RestResource):
def get_query(self):
identifier = get_identifier()
student = Student.get(Student.identifier == identifier)
from = datetime.now().replace(hour=0, minute=0, second=0, microsecond=0)
to = datetime(2014, 6, 15)
return self.model.select().where(Session.date.between(from, to)).join(Activity).join(Course).join(StuCouRel).join(Student).where(Student.id == student.id).order_by(Session.date, Session.begin_time, Session.end_time)
paginate_by = None
include_resources = {
'activity': ActivityResource,
'course': CourseResource
}
exclude = ('id')
this will output something like this:
[
{
"duration": 7200,
"activity": {
"name": "MyActivityName"
},
"course": {
"name": "MyCourseName"
},
"end_time": "18:00",
"begin_time": "16:00",
"date": "03-04-2014"
},
...
]
what I would like to get, however, is this:
[
{
"duration": 7200,
"activity": "MyActivityName",
"course": "MyCourseName",
"end_time": "18:00",
"begin_time": "16:00",
"date": "03-04-2014"
},
...
]
I have read the docs and tried reading the source code itself, but I can't really figure out how to make it work. Any help would be appreciated.