I have a checkbox choice field like this:
models.py
TYPE_CHOICES = (
('s', 'small'),
('m', 'medium'),
('b', 'big'),
)
class Post(models.Model) :
size = models.CharField(blank=True,max_length="3", choices=TYPE_CHOICES)
So in the admin form:
class MainContent(forms.ModelForm):
size = forms.MultipleChoiceField(choices=TYPE_CHOICES, widget=forms.CheckboxSelectMultiple())
class Meta:
model = Post
fields = '__all__'
But when I saving the form it give me this error:
Select a valid choice. ['s', 'm', 'b'] is not one of the available choices.
So, what is the problem?
UPDATE
My apology, this question was not given enough info, let me explain more.
The reason I want a checkbox input is because I want it able to store multiple values in the single field (one column). Perhaps the data can be serialized (or comma separated),
Since the TYPE_CHOICES is static and will not changed in the future, I am not planning to use ManytoMany.
Also I want it able to display in the template easily by the language language.
Hope this is clear enough.