burke-software / django-report-utils

Common functions used for reporting needs. Used by django-report-builder and django-report-scaffold.
Other
10 stars 27 forks source link

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

Open fyaconiello opened 10 years ago

fyaconiello commented 10 years ago

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])