diff --git a/survey/forms.py b/survey/forms.py index 833961f7..c6418400 100644 --- a/survey/forms.py +++ b/survey/forms.py @@ -5,7 +5,6 @@ from django.conf import settings from django.forms import models from django.urls import reverse -from django.utils.text import slugify from survey.models import Answer, Category, Question, Response, Survey from survey.signals import survey_completed @@ -164,18 +163,15 @@ def get_question_initial(self, question, data): if answer: # Initialize the field with values from the database if any if question.type == Question.SELECT_MULTIPLE: - initial = [] if answer.body == "[]": - pass - elif "[" in answer.body and "]" in answer.body: initial = [] - unformated_choices = answer.body[1:-1].strip() - for unformated_choice in unformated_choices.split(settings.CHOICES_SEPARATOR): - choice = unformated_choice.split("'")[1] - initial.append(slugify(choice)) + elif answer.body[0] == "[" and answer.body[-1] == "]": + initial = [ + choice.strip(" '") for choice in answer.body.strip("[]").split(settings.CHOICES_SEPARATOR) + ] else: # Only one element - initial.append(slugify(answer.body)) + initial = [answer.body] else: initial = answer.body if data: diff --git a/survey/models/question.py b/survey/models/question.py index 7b08720b..76b7f025 100644 --- a/survey/models/question.py +++ b/survey/models/question.py @@ -372,7 +372,7 @@ def get_choices(self): """ choices_list = [] for choice in self.get_clean_choices(): - choices_list.append((slugify(choice, allow_unicode=True), choice)) + choices_list.append((choice, choice)) choices_tuple = tuple(choices_list) return choices_tuple