1👍
Your LanguageLevel
model is missing a ForeignKey
to the UserProfile
:
class LanguageLevel(models.Model):
language = models.ForeignKey(Language)
level = models.ForeignKey(Level)
# Add Foreign Key to UserProfile
userprofile = models.ForeignKey(UserProfile)
class Meta:
unique_together = (('level', 'language'),)
Also I’m not sure that the unique_together
constraint is what you want – it will mean that only one user can have any one combination of language/level. A more likely constraint would be ('userprofile', 'language')
so that a language can only be mapped to a user once.
Source:stackexchange.com