I have two diferents problems with multple choices in models.
The first, i'm trying to do a multiple choice so the user can pick one or more days of the week:
DAYS_CHOICES = (
(1, _('Monday')),
...
(7, _('Sunday')),
)
...
day = models.ManyToManyField('day', choices=DAYS_CHOICES)
The second problem:
I want to make a ManyToMany Relation with a model define in other model: First (Import to the model):
from events.models import Category
Second (The field related to the model):
type = models.ManyToManyField('Category', null=True, blank=True)
I get this error on syncdb:
Error: One or more models did not validate: situ.situ: 'day' has an m2m relation with model day, which has either not been installed or is abstract.
situ.situ: 'type' has an m2m relation with model Category, which has either not been installed or is abstract.
For the first part of your questions. You should be using a
MultipleChoiceField
http://docs.djangoproject.com/en/dev/ref/forms/fields/#multiplechoicefield
This will yield a list of Unicode objects.
For the second problem, You need to either include the app name in the abstract declaration of the model in the m2m field or not declare it abstractly.
or
If the
Category
model was defined later in the same app in the models.py you could leave itCategory
but since it is in another app, you need to specify the app name.