coleifer / django-relationships

Descriptive relationships between auth.users (think facebook friends and twitter followers, plus more)
http://django-relationships.readthedocs.org
MIT License
370 stars 98 forks source link

models do not validate #10

Closed kanarelo closed 13 years ago

kanarelo commented 13 years ago

Hye, Am Ian, working on a project... Trying to inco-operate the app to my django project... I was doing testing, and the following error is shown:

Error: One or more models did not validate: auth.user: Accessor for m2m field 'relationships' clashes with related m2m field 'User.related_to'. Add a related_name argument to the definition for 'relationships'. auth.user: Reverse query name for m2m field 'relationships' clashes with related m2m field 'User.related_to'. Add a related_name argument to the definition for 'relationships'. auth.user: The model User has two manually-defined m2m relations through the model Relationship, which is not permitted. Please consider using an extra field on your intermediary model instead. auth.user: Accessor for m2m field 'relationships' clashes with related m2m field 'User.related_to'. Add a related_name argument to the definition for 'relationships'. auth.user: Reverse query name for m2m field 'relationships' clashes with related m2m field 'User.related_to'. Add a related_name argument to the definition for 'relationships'.

I believe it has to something with the hack you have in models.py file:

HACK

field = models.ManyToManyField(User, through=Relationship, symmetrical=False, related_name='related_to')

TODO: Look into this issue; Remove The comment below after Tests #field.contribute_to_class(User, 'relationships')

I thought I could avoid the issue by commenting out the parts, but, I get a diffent error altogether :

ERROR: test_site_behavior (relationships.tests.tests.RelationshipsTestCase)

Traceback (most recent call last): File "/home/ian/workspace/myproject/src/myproject/util/core/relationships/tests/tests.py", line 231, in test_site_behavior self.assertQuerysetEqual(self.walrus.relationships.all(), [self.john, self.paul]) File "/usr/lib/pymodules/python2.6/django/db/models/manager.py", line 117, in all return self.get_query_set() File "/usr/lib/pymodules/python2.6/django/db/models/fields/related.py", line 484, in get_query_set return superclass.get_query_set(self).using(db)._next_issticky().filter(*(self.core_filters)) File "/usr/lib/pymodules/python2.6/django/db/models/query.py", line 550, in filter return self._filter_or_exclude(False, args, _kwargs) File "/usr/lib/pymodules/python2.6/django/db/models/query.py", line 568, in _filter_or_exclude clone.query.add_q(Q(_args, *_kwargs)) File "/usr/lib/pymodules/python2.6/django/db/models/sql/query.py", line 1128, in add_q can_reuse=used_aliases) File "/usr/lib/pymodules/python2.6/django/db/models/sql/query.py", line 1026, in add_filter negate=negate, process_extras=process_extras) File "/usr/lib/pymodules/python2.6/django/db/models/sql/query.py", line 1191, in setup_joins "Choices are: %s" % (name, ", ".join(names))) FieldError: Cannot resolve keyword 'related_to' into field. Choices are: _message_set, avatar, date_joined, email, emailvalidation, first_name, forum_post_set, from_users, groups, id, is_active, is_staff, is_superuser, last_login, last_name, logentry, originating_user, password, rate, reputation, subscription, target_user, to_users, user_permissions, username, vote

Please check this out... Cheers.

coleifer commented 13 years ago

Hey thanks for bringing this to my attention. Couple questions... do you get the validation error when running tests? I ask bc I wonder if another model in your project is conflicting w/djangorelationships.

Next question, what version and rev of django are you using?

kanarelo commented 13 years ago

I do not have any other app/project installed, that is conflicting with django-relationships, because I have carefully analysed the models... I have used the app before, but I have never tested it. I only used it once to make a demo app. Speaking of which, I was able to be-friend/follow myself [isn't that a bug?]. I am using django 1.2.3 release.

I got the error while running "manage.py test" I also tried to input 'relationships.tests' in the apps tuple.

coleifer commented 13 years ago

hmm, i'm running django 1.2.3 Final

In [1]: import django

In [2]: django.VERSION
Out[2]: (1, 2, 3, 'final', 0)

then if i change dirs into django-relationships/relationships/tests/ and run django-admin.py test --settings=settings I get:

Installing json fixture 'initial_data' from '/home/charles/pypath/relationships/fixtures'.
Installed 2 object(s) from 1 fixture(s)
........................................................................................
----------------------------------------------------------------------
Ran 88 tests in 1.857s

I think the problem might be in your models

kanarelo commented 13 years ago

Geez... Lemme check this thing overnight... I hope to clear up something... cheers.

kanarelo commented 13 years ago

I forgot to post back. I was the one mixing namespaces in my application. i was able to run the program well.