AbstractProblemFactory
AbstractProblemFactory

Reputation: 9811

Many choices in one model's field?

I have

`   CATEGORY_CHOICES = (
        ('A', 'B', 'C')
    )`

and I would let field:

myChoice = models.CharField(choices=CATEGORY_CHOICES)

have many values from CATEGORY_CHOICES (1-3).

I am just starting use Django so an example will be nice :)

Upvotes: 0

Views: 757

Answers (2)

Jack M.
Jack M.

Reputation: 32070

Are you horribly opposed to using a ManyToMany relationship? This relationship type is designed for exactly what you're trying to do. It would create another table in the database instead of being a list in Python, but it would get the job done.

Upvotes: 0

lprsd
lprsd

Reputation: 87095

You may want to use

myChoice = models.CommaSeparatedIntegerField()

Upvotes: 1

Related Questions