pivot table - Django-Chartit2 'dict_keys' object does not support indexing error -
i exploring django chartit2 package charting purpose following demo examples provided here. have created own model pivot charts contains fields: city, person , sales.
in views creating pivotchart making use of term based on aggregation of sales column.
while trying accessing url getting error:
exception type: typeerror @ /chart/pivotpool/
exception value: 'dict_keys' object not support indexing
let me know missing while specifying terms pivotchart.
class saleshistory(models.model): city = models.charfield(max_length=50) person = models.charfield(max_length=50) sales_qty = models.integerfield() def some_view(request): ds = pivotdatapool(series=[{'options': {'source': saleshistory.objects.all(), 'categories': ['city']}, 'terms': {'total_sales': sum('sales_qty')}}]) pivchrt = pivotchart(datasource=ds, series_options=[{'options': {'type': 'column', 'stacking': true}, 'terms':['total_sales']}], chart_options = {})
my traceback:
traceback: file "/home/sam/documents/onemoreenv/lib/python3.4/site-packages/django/core/handlers/base.py" in get_response 149. response = self.process_exception_by_middleware(e, request) file "/home/sam/documents/onemoreenv/lib/python3.4/site-packages/django/core/handlers/base.py" in get_response 147. response = wrapped_callback(request, *callback_args, **callback_kwargs) file "/home/sam/documents/lab projects/djangochartit/demochartit/views.py" in some_view 131. 'text': 'city'}}}) file "/home/sam/documents/onemoreenv/lib/python3.4/site-packages/chartit/charts.py" in __init__ 508. self.set_default_hcoptions() file "/home/sam/documents/onemoreenv/lib/python3.4/site-packages/chartit/charts.py" in set_default_hcoptions 533. categories = dss[terms[0]]['categories']
the terms being used in set_default_hcoptions function in charts.py file of chartit has no attribute index, thats reason giving error me. have commented line gets initialised i.e.
# terms = self.series_options.keys()
and have added own version of it:
terms = list(self.series_options)
and worked me.
Comments
Post a Comment