Permalink
Browse files

Merge pull request #21 from paltman/django-1.4

Django 1.4
  • Loading branch information...
2 parents 394a951 + c9f6df8 commit a26660a8a29d74a66669da1a0d8b2b8d4db03ee8 @coleifer committed Mar 9, 2012
Showing with 22 additions and 2 deletions.
  1. +1 −1 relationships/__init__.py
  2. +21 −1 relationships/models.py
View
2 relationships/__init__.py
@@ -1 +1 @@
-VERSION = (0, 3, 0)
+VERSION = (0, 3, 1)
View
22 relationships/models.py
@@ -239,7 +239,7 @@ def __get__(self, instance, instance_type=None):
)
return manager
-else:
+elif django.VERSION > (1, 2) and django.VERSION < (1, 4):
fake_rel = ManyToManyRel(
to=User,
@@ -258,6 +258,26 @@ def __get__(self, instance, instance_type=None):
target_field_name='to_user'
)
return manager
+
+else:
+
+ fake_rel = ManyToManyRel(
+ to=User,
+ through=Relationship)
+
+ RelatedManager = create_many_related_manager(RelationshipManager, fake_rel)
+
+ class RelationshipsDescriptor(object):
+ def __get__(self, instance, instance_type=None):
+ manager = RelatedManager(
+ model=User,
+ query_field_name='related_to__pk',
+ instance=instance,
+ symmetrical=False,
+ source_field_name='from_user',
+ target_field_name='to_user'
+ )
+ return manager
#HACK
field.contribute_to_class(User, 'relationships')

0 comments on commit a26660a

Please sign in to comment.