I know there isn't
MultipleChoiceField for a Model, you can only use it on Forms.
Today I face an issue when analyzing a new project related with Multiple Choices.
I would like to have a field like a
choices with the option of multiple choice.
I solved this issue other times by creating a
CharField and managed the multiple choices in the form with a
forms.MultipleChoiceField and store the choices separated by commas.
In this project, due to configuration, I cannot do it as I mention above, I need to do it in the Models, and I prefer NOT to edit the Django admin form neither use forms. I need a Model Field with multiple choices option
- Have someone solved anything like this via Models ?
Maybe overriding some of the models function or using a custom widget… I don't know, I'm kinda lost here.
I'm aware off simple choices, I would like to have something like:
class MODEL(models.Model): MY_CHOICES = ( ('a', 'Hola'), ('b', 'Hello'), ('c', 'Bonjour'), ('d', 'Boas'), ) ... ... my_field = models.CharField(max_length=1, choices=MY_CHOICES) ...
but with the capability of saving multiple choices not only 1 choice.