Skip to content

KeyError when choices removed but historic data remains in DB #6

@fyaconiello

Description

@fyaconiello

https://github.com/burke-software/django-report-utils/blob/master/report_utils/mixins.py#L361

If for some reason a choice field's choice gets removed, but there is historic data pointing to that choice, this line throws the following error.

File "/home/ubuntu/web/......./venv/local/lib/python2.7/site-packages/report_utils/mixins.py", line 361, in report_to_list
row[position-1] = unicode(choice_list[row[position-1]])
KeyError: u'NY '

I monkey patched that line with this for now on my install:

try:
    row[position-1] = unicode(choice_list[row[position-1]])
except:
    row[position-1] = unicode(row[position-1])

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions