Найти - Пользователи
Полная версия: django 1.6.5 ошибка модели
Начало » Django » django 1.6.5 ошибка модели
1
eboome
здраствуйте
вот моя модель:
class Organizations(models.Model):
    org_id = models.IntegerField(primary_key=True)
class Profiles(models.Model):
    org_id=models.OneToOneField(Organizations, related_name='org_id')
и когда я в терминале делаю sql то у меня ошибка:

CommandError: One or more models did not validate:
main_sid.profiles: Accessor for field 'org_id' clashes with field 'Organizations.org_id'. Add a related_name argument to the definition for 'org_id'.
main_sid.profiles: Reverse query name for field 'org_id' clashes with field 'Organizations.org_id'. Add a related_name argument to the definition for 'org_id'.

в чём причина? Спасибо
Rebra4
имена полей одинаковы
В модели Organizations нужно сменить название поля или в другой.
eboome
Rebra4
имена полей одинаковыВ модели Organizations нужно сменить название поля или в другой.
это ничего не меняет, всё так же само
Rebra4
class Organizations(models.Model):
    org_id2 = models.IntegerField(primary_key=True)
class Profiles(models.Model):
    org_id=models.OneToOneField(Organizations, related_name='org_id')
У меня работает так
inoks
class Organizations(models.Model):
    org_id = models.IntegerField(primary_key=True)
class Profiles(models.Model):
    org_id=models.OneToOneField(Organizations, related_name='org_id')


related_name='org_id' означает что из класса Organizations можно перейти в Profiles по через org_id, но такое поле уже есть в Organizations.

Укажите или другое имя поля в Organizations или другое related_name в Profiles
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