def __init__(self, user, *args, **kwargs):
        self.report_id = None
        if 'report_id' in kwargs:
            self.report_id = kwargs.pop('report_id')
        if 'chart_id' in kwargs:
            self.chart_id = kwargs.pop('chart_id')
            chart = get_object_or_404(Chart, pk=self.chart_id)
            self.report_id = chart.report_id

        super(ChartForm, self).__init__(*args, **kwargs)
        if not self.report_id:
            return

        report = get_object_or_404(Report, pk=self.report_id)
        chart = None
        if hasattr(self, 'chart_id'):
            chart = get_object_or_404(Chart, pk=self.chart_id)

        model = loads(report.model)

        object = model.name
        object = object.split('.')

        module_name = object[0] + '.' + object[1] + '.' + object[2]
        import_name = object[3]

        module = __import__(
            module_name, globals(), locals(), [import_name], -1)
        classobj = getattr(module, import_name)

        unfiltered_set = classobj.objects.exclude(trash=True)

        set = []
        for s in unfiltered_set:
            filtered = False
            for field in model.fields:
                if field.filters and str(getattr(s, field.name)) not in field.filters:
                    filtered = True
            if not filtered:
                set.append(s)

        # perhaps do type checking on a setting list of types (for each type)
        self.fields['grouping'].choices = [('', '--------')]

        # Check for group
        groupname = None
        groups = None
        for field in model.fields:
            self.fields['grouping'].choices.append(
                (str(field.name), str(field.name).replace('_', ' ').title()))
            if field.groupby == 1:
                self.fields['grouping'].initial = str(field.name)

        if chart:
            options = loads(chart.options)
            for f in options:
                if f in self.fields:
                    self.fields[f].initial = options[f]
dataset/ETHPy150Open treeio/treeio/treeio/reports/forms.py/ChartForm.__init__/original