4

When trying to syncdb with the following models:

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))

I get the following error:

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'.
Antonio
  • 41
  • 2
  • 1
    I copied your code snippet to a test app and run syncdb and it works. I think there maybe some other details you did not mentioned here. – satoru Apr 07 '10 at 14:04
  • I have the same problem when I run test, but in Syncdb and on saving objects with the shell it works. I still need the test :-s. – Fitoria Nov 17 '10 at 15:44
  • I don't think you're telling us everything. Are you using an external app to enhance the User model? – Honza Pokorny Nov 21 '10 at 14:18

1 Answers1

0

See Carl's answer to this question Django: Model name clash

Community
  • 1
  • 1
Thomas Schreiber
  • 1,828
  • 2
  • 14
  • 11