Toy problem: I have a list of persons and a sublist of it are friends. Each list shouldn't have duplicates (it means there is no more than one guy with a given pair <name,surname>, I know it's not a good assumption in general but this is a toy example ;). So I made two models (Person, Friend) the first having the constraint "unique_together = (("name","surname"),)" and the second (made of just a reference to Person) having unique=True. This last constraint doesnt'work, giving a long traceback in admin interface. How should I express this constraint in the proper way? What's wrong? Example code follows.
Thanks in advance, Emanuele --------------------------------------------------- from django.core import meta class Person(meta.Model): name = meta.CharField("Name",maxlength=30) surname = meta.CharField("Surname",maxlength=30) def __repr__(self): return "%s %s" % (self.name,self.surname) class META: unique_together = (("name","surname"),) admin = meta.Admin() pass pass class Friend(meta.Model): person = meta.ForeignKey(Person,verbose_name="Friend",unique=True) def __repr__(self): return "%s" % (self.get_person()) class META: admin = meta.Admin() pass pass -------------------------------------------------------