Hello, I have a model that has a foreign key field that I want to use in a form as a select box. That particular field at times appears multiple times in the database. How do I make it only have distinct values?
This is a snippet, drop down will have repeated values if same color is entered: class FavoriteColor(models.Model): color = models.CharField(max_length=255) def __unicode__(self): return self.color class FavoriteThings(models.Model): name = models.CharField(max_length=10) color = models.ForeignKey(FavoriteColor) class FavoriteThingsForm(forms.ModelForm): class Meta: model = FavoriteThings Thank you -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.