0

I have a Django application and want to display multiple choice checkboxes in a user's profile. They will then be able to select multiple items.

I am able save the data in the database, but it is saving like '[u'A', u'B']'.

What should i do to save the selections in a list?

Thanks a lot in advance.

1 Answers1

2

It would help if you could be a bit more specific about the issue.

  • If you are unable to fetch the values of all the checkboxes and are getting only the last value, you are probably trying to use a get() method instead of a getlist() method. Kind of goes like this:

    op = request.POST.getlist('MultipleChoiceField')
    
  • What you are storing currently (as shown in the desc above) is also a list, just that it is a list of unicode strings. If that is the issue, you should do something like this.

    op = []
    for x in op:
        op.append(str(x))
    
Chetan
  • 1,724
  • 2
  • 14
  • 18