cannot loaddata with choices
johanneswilm opened this issue · comments
When I try to dumpdata and subsequently loaddata, I get a large amount of errors thrown. This seems to be due to choices being converted to their slug equivalent when saving to the database while the original choices values are checked for.
File ".../python-3.11.2/lib/python3.11/site-packages/survey/models/answer.py", line 87, in check_answer_for_select
raise ValidationError(msg)
django.core.exceptions.ValidationError: ["Impossible answer 'spiser-ikke-fisk' should be in ['Spiser ikke fisk', 'Spiser ofte fisk', 'Spiser fisk hver dag', 'Spiser overvejende fisk', 'Spiser kun fisk'] "]
A quick fix: override https://github.com/Pierre-Sassoulas/django-survey/blob/main/survey/models/question.py#L376 to not use slugify. That way the original values are storied, not the slugified ones.
Can you open a merge request with this fix @johanneswilm, please ? I'm not sure what tests will break but I don't remember exactly why I did that in the first place.