Hello!
I have added a few new fields to my model called Profile and get an error when trying to create migrations.
Have anyone else encountered similar error? What causes it and how did you solve it?
Model:
class Profile(models.Model):
member = models.OneToOneField(Member, on_delete=models.CASCADE)
hetero_man_hair_color = models.CharField(max_length=100, blank=True, choices=hair_color)
hetero_man_eye_color = models.CharField(max_length=10, blank=True, choices=eye_color)
hetero_man_ethnicity = models.CharField(max_length=50, blank=True, choices=ethnicity)
last_login_from_country = models.CharField(max_length=100, default="")
last_login_from_city = models.CharField(max_length=100, default="")
hit_count = models.PositiveIntegerField(default=0)
profile_likes = models.IntegerField(default=0)
class Meta:
verbose_name = "Användarprofil"
verbose_name_plural = "Användarprofiler"
def __str__(self):
return str(self.member)
def get_absolute_url(self):
return reverse("profilepage_app:profile-redirect", args=[self.member.username_slug])
Error:
profile_app.Profile.hetero_man_hair_color: (fields.E004) 'choices' must be a mapping (e.g. a dictionary) or an iterable (e.g. a list or tuple).
profile_app.Profile.hetero_man_eye_color: (fields.E004) 'choices' must be a mapping (e.g. a dictionary) or an iterable (e.g. a list or tuple).
profile_app.Profile.hetero_man_ethnicity: (fields.E004) 'choices' must be a mapping (e.g. a dictionary) or an iterable (e.g. a list or tuple).
hair_color = (("Blond", "Blond"), ("Svart", "Svart"), ("Brun", "Brun"), ("Röd", "Röd"), ("Annat", "Annat"))
eye_color = (("Gröna", "Gröna"), ("Blå", "Blå"), ("Brun", "Brun"), ("Grå", "Grå"), ("Nötbrun", "Nötbrun"), ("Röda", "Röda"), ("Annat", "Annat"))
ethnicity = (("Europisk", "Europisk"), ("Asiat", "Asiat"), ("Afrikan", "Afrikan"), ("Nordamerikank", "Nordamerikank"), ("Latino", "Latino"), ("Annat", "Annat"),)
What I can see I am using nested tuple, which is an iterable and it did work prior adding the new fields.
All help is appriciated.