On Feb 7, 11:44 am, Jaroslav Dobrek <jaroslav.dob...@gmail.com> wrote: > Hello, > > how can I create a field that contains tuples of entities? An example: > A model "Candidate" (someone who applies for a job) might have a field > "languages" which is a list of tuples consisting of a language and a > proficiency level.
As others have said: don't. If you ever need to do any DB queries involving the proficiencies of the candidates (like "how many candidates we have who are proficient in English") you are screwed. You will most likely get what you want with: class CandidateLangProficiency(models.Model): candidate = models.ForeignKey(Candidate, related_name='proficiencies') lang = models.CharField(max_length=2, choices=(('fi', 'Finnish'), ...) # Or a foreign key. proficiency = models.IntegerField(choices=...) class Meta: unique_together = ('candidate', 'lang') If you can use Django 1.4, its prefetch_related will be your friend. If you really know what you are doing you can write a custom model field. Django's documentation should contain examples of that. - Anssi -- 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.