Here is how my form is set up (all the fields are the same):
class AddColourForm(forms.Form):
colour = forms.CharField(
widget=TextInput(attrs={'class':'form-control'}),
max_length=100,
required=False,
label = "Colour:",
)
Here is my view:
if form.is_valid():
selected_colour.code = form.cleaned_data['code'],
selected_colour.name = form.cleaned_data['colour'],
selected_colour.save()
Here is what happens when it goes into the db:
(u'red',) (u'#ff0000',)
I have tried adding unicode() wrappers around the cleaned data before saving but that isn't working.
Does anyone have any other suggestions?
Try removing the commas after each line like so (they aren't necessary):
selected_colour.code = form.cleaned_data['code']
selected_colour.name = form.cleaned_data['colour']
selected_colour.save()
it looks like the commas are turning your data into a list.