-
Notifications
You must be signed in to change notification settings - Fork 29
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Compatibility with 1.7 & 1.8a1 #21
Conversation
> RemovedInDjango18Warning: `BaseManager.get_query_set` is deprecated, use `get_queryset` instead. and > RemovedInDjango18Warning: `RelatedManager.get_query_set` method should be renamed `get_queryset`.
> RemovedInDjango19Warning: django.contrib.contenttypes.generic is deprecated and will be removed in Django 1.9. > Its contents have been moved to the fields, forms, and admin submodules of django.contrib.contenttypes.
Are these changes compatible with 1.5 and 1.6, though? |
Good question — we need a
The The final change was just to the test runner. |
Here's the relevant discussion from the 1.6 release notes: get_query_set and similar methods renamed to get_queryset |
OK. I added the fallback as per the docs. However, running against 1.5. leads to breakage on the How would you want that handled? |
It occurred to me that, with 1.8 around the corner, the best option might actually be to drop any support for Django 1.5 — no-one's building anything new with it now right, and the existing release will continue to work. This prompted me to check Django's supported versions which itself does not include 1.5. (Please don't mention the LTS version 😀) Do you have any particular stance on that suggestion? |
Yeah, that makes sense -- people could just pin an older version. |
I needed to make the following changes to get it to work with 1.6, diff --git a/genericm2m/models.py b/genericm2m/models.py
index 9b942d4..d9df639 100644
--- a/genericm2m/models.py
+++ b/genericm2m/models.py
@@ -136,7 +136,12 @@ class RelatedObjectsDescriptor(object):
qs = GFKOptimizedQuerySet(self.model, gfk_field=rel_field)
return qs.filter(**(core_filters))
else:
- return superclass.get_queryset(self).filter(**(core_filters))
+ if django.VERSION < (1, 6):
+ method = superclass.get_query_set
+ else:
+ method = superclass.get_queryset
+
+ return method(self).filter(**(core_filters))
if django.VERSION < (1, 6):
get_query_set = get_queryset
@@ -190,7 +195,11 @@ class RelatedObjectsDescriptor(object):
)
def symmetrical(self):
- return superclass.get_queryset(self).filter(
+ if django.VERSION < (1, 6):
+ method = superclass.get_query_set
+ else:
+ method = superclass.get_queryset
+ return method(self).filter(
Q(**rel_obj.get_query_from(instance)) |
Q(**rel_obj.get_query_to(instance))
).distinct()
diff --git a/runtests.py b/runtests.py
index 428189d..9ccfc90 100755
--- a/runtests.py
+++ b/runtests.py
@@ -27,7 +27,10 @@ if not settings.configured:
from django.test.utils import get_runner
-django.setup()
+try:
+ django.setup()
+except AttributeError:
+ pass
def runtests(*test_args):
if not test_args: Did you actually test this on 1.6 or 1.7? |
Oooops, my bad. My pythonpath was pointing to a django 1.5. So if we want 1.5 compat, the changes above are all that's necessary. |
Compatibility with 1.7 & 1.8a1
Merged and applied the 1.5 compatibility fixes. Thanks for your help with this! |
No worries. Thanks for the software! (And for putting the changes on PyPI so promptly)
|
Fixes #20.