Skip to content
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

Merged
merged 4 commits into from
Jan 24, 2015
Merged

Conversation

carltongibson
Copy link
Contributor

Fixes #20.

Carlton Gibson added 3 commits January 23, 2015 16:13
> 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.
@coleifer
Copy link
Owner

Are these changes compatible with 1.5 and 1.6, though?

@carltongibson
Copy link
Contributor Author

Good question — we need a tox matrix.

get_queryset changed in 1.6 — I'd need to see how people handle that.

The GFK import should be backwards compatible.

The final change was just to the test runner.

@carltongibson
Copy link
Contributor Author

Here's the relevant discussion from the 1.6 release notes: get_query_set and similar methods renamed to get_queryset

@carltongibson
Copy link
Contributor Author

OK. I added the fallback as per the docs.

However, running against 1.5. leads to breakage on the superclass.get_queryset(self) calls.

How would you want that handled?

@carltongibson
Copy link
Contributor Author

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?

@coleifer
Copy link
Owner

Yeah, that makes sense -- people could just pin an older version.

@coleifer
Copy link
Owner

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?

@coleifer
Copy link
Owner

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.

coleifer added a commit that referenced this pull request Jan 24, 2015
Compatibility with 1.7 & 1.8a1
@coleifer coleifer merged commit 855d6d4 into coleifer:master Jan 24, 2015
@coleifer
Copy link
Owner

Merged and applied the 1.5 compatibility fixes. Thanks for your help with this!

@carltongibson
Copy link
Contributor Author

No worries. Thanks for the software! (And for putting the changes on PyPI so promptly)

On 24 Jan 2015, at 05:33, Charles Leifer notifications@github.com wrote:

Merged and applied the 1.5 compatibility fixes. Thanks for your help with this!


Reply to this email directly or view it on GitHub.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Deprecation warnings.
2 participants