Permalink
Browse files

Make compatible with Django 1.4

  • Loading branch information...
1 parent 394a951 commit 92d798c4728aa8985701bb62bb977227674c2a8d @paltman paltman committed Mar 9, 2012
Showing with 21 additions and 1 deletion.
  1. +21 −1 relationships/models.py
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 92d798c

Please sign in to comment.