I have a table with a list of corporations; each corp has a field with it unique number. There is a table, filled with people, each record contains a field with a corp's unique field (where each person works)
Task: when displaying info about corporation, also fetch info about people working at. Also there are several tables with such relationship with a corp table. So, it seems to be a many-to-many relationship. there is come code class c12b (models.Model): id = models.AutoField (primary_key=True) A15 = models.CharField ('Телетайп', max_length=20, blank= True) A17 = models.CharField ('Телекс', max_length=20, blank= True) A19 = models.CharField ('Факс', max_length=40, blank= True) A34 = models.CharField ('Код промышленности',max_length=5, blank=True) A29 = models.CharField ('E-mail', max_length=50, blank=True) A30 = models.CharField ('Сайт', max_length=40, blank= True) A3 = models.CharField ( 'ИНН',max_length=10, blank=True) A21 = models.CharField ('Реквизиты банка' ,max_length=255, blank=True) A22 = models.CharField ('Код ОКПО', max_length=8, blank=True ) #CORP INIQUE KEY #here I've tried to create a related field boss = models.ManyToManyField (Dolgnost, db_column="A22", through='bosses_table') class Meta: db_table='C12B' class bosses_table (models.Model): c12b = models.ForeignKey (c12b, to_field="A22") dolgnost = models.ForeignKey (Dolgnost, to_field="A22",unique=False) #in view.py ... result = c12b.objects.filter(A34__exact ="02100") return render_to_response ("prkp/lista.html", { "result":result, ... #template {% for i in result %} <tr> {% for b in i.boss.all %} {{ b.U1 }} {% endfor %} <td>{{ i.boss.U1 }}</td> Finally I've got an exeption Caught an exception while rendering:relation "search_bosses_table" doesn't exist syncdb says psycop2.ProgrammingError: there is no unique constaint mathing given keys for reference table "C12B" Please, show me a right way (I'm thinking of creating my manager with a raw sql for this) --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---