4
При попытке SyncDB со следующими моделями:Джанго M2M Пользователь отношения
class Contact(models.Model):
user_from = models.ForeignKey(User,related_name='from_user')
user_to = models.ForeignKey(User, related_name='to_user')
class Meta:
unique_together = (('user_from', 'user_to'),)
User.add_to_class('following', models.ManyToManyField('self', through=Contact, related_name='followers', symmetrical=False))
Я получаю следующее сообщение об ошибке: Ответ
Error: One or more models did not validate:
auth.user: Accessor for m2m field 'following' clashes with related m2m field 'User.followers'. Add a related_name argument to the definition for 'following'.
auth.user: Reverse query name for m2m field 'following' clashes with related m2m field 'User.followers'. Add a related_name argument to the definition for 'following'.
auth.user: The model User has two manually-defined m2m relations through the model Contact, which is not permitted. Please consider using an extra field on your intermediary model instead.
auth.user: Accessor for m2m field 'following' clashes with related m2m field 'User.followers'. Add a related_name argument to the definition for 'following'.
auth.user: Reverse query name for m2m field 'following' clashes with related m2m field 'User.followers'. Add a related_name argument to the definition for 'following'.
я скопировал код фрагмент тестового приложения и запуск syncdb, и он работает. Я думаю, что, может быть, некоторые другие подробности вы не упомянули здесь. – satoru
У меня такая же проблема, когда я запускаю тест, но в Syncdb и при сохранении объектов с оболочкой он работает. Мне все еще нужен тест: -s. – Fitoria
Я не думаю, что вы рассказываете нам все. Используете ли вы внешнее приложение для улучшения модели пользователя? –