Найти - Пользователи
Полная версия: (1110, "Column 'id' specified twice")
Начало » Django » (1110, "Column 'id' specified twice")
1
anbu
Доброй ночи.

Столкнулся с небольшой проблемкой:

кусок models.py:
class Column(models.Model):
describe = models.CharField(max_length=255, blank=True)
type_col = models.ForeignKey(TypeColumn, null=True, db_column='id_type', blank=True)
disc = models.ForeignKey(Discipline, null=True, db_column='id', blank=True)
group = models.ForeignKey(Groups, null=True, db_column='id', blank=True)

class Meta:
db_table = u'column'
ordering = ['date']

def __unicode__(self):
return u'%s, %s' %(self.type_col, self.describe)
кусок views.py:
Column.objects.create(type_col=TypeColumn.objects.get(id=request.POST['type_col']),
describe=request.POST['describe'],
disc=Discipline.objects.get(id=iddisc),
group=Groups.objects.get(id=idgroup))
При попытке записи данных выдает ошибку (1110, “Column ‘id’ specified twice”).
В принципе, мне понятна ошибка. Вся беда в этом:
    disc = models.ForeignKey(Discipline, null=True, db_column='id', blank=True)
group = models.ForeignKey(Groups, null=True, db_column='id', blank=True)
Возникает вопрос - можно ли решить проблему не меняя названия столбцов и PK в таблице?
Заранее благодарен.
Ferroman
А как это вы себе представляете — замапить два ключа на одно и то же поле в таблице?
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Powered by DjangoBB