I have a UserProfile where the User chose a language. Users should have the possibility to chose more than one language so i tried to use a ManyToManyField like so:
class Choices(models.Model):
languages = models.CharField(choices=settings.LANGUAGES, max_length=3)
def __unicode__(self):
return self.languages
class UserProfile(models.Model):
user = models.OneToOneField(User, null=True)
language = models.ManyToManyField(Choices)
in my form.py i did:
class UserProfileForm(forms.ModelForm):
language = forms.MultipleChoiceField(required=False, choices=settings.LANGUAGES)
class Meta:
model = UserProfile
fields=[
'Pictures',
.....
]
The problem is: The choices are shown in the template but in the admin the ManyToManyField is empty. So the Form works but the Model does not. Can somebody tell me why no Options are displayed? Where is the mistake at the M2M?