Extra DateField in SQL

This chart plots sales quantities per day from the first book store. In the RawQuerySet we select extra fields, which are not defined inside the model.

code

ds = DataPool(
        series=[{
            'options': {
                # NOTE: strftime is SQLite function.
                # For MySQL use DATE_FORMAT
                'source': SalesHistory.objects.raw(
                            "SELECT id, sale_qty, "
                            "strftime('%%Y/%%m/%%d', sale_date) as sold_at"
                            " FROM demoproject_saleshistory "
                            "WHERE bookstore_id=%s LIMIT 10",
                            [BookStore.objects.first().pk]
                          )

            },
            'terms': [
                'sold_at',
                'sale_qty',
            ]
        }]
)

cht = Chart(
        datasource=ds,
        series_options=[{
            'options': {
                'type': 'line',
                'stacking': False
            },
            'terms': {
                'sold_at': [
                    'sale_qty',
                ]
            }
        }],
        chart_options={
            'title': {
                'text': 'Sales QTY per day'
            },
            'xAxis': {
                'title': {
                    'text': 'Sale date'
                }
            }
        }
)