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

Use related_objects api for Django 1.9+ #3656

Merged
merged 1 commit into from Nov 19, 2015

Conversation

andreif
Copy link
Contributor

@andreif andreif commented Nov 18, 2015

Closes #3252.

@andreif andreif changed the title Fixes #3252 -- Use related_objects api for Django 1.9+ Fix #3252 -- Use related_objects api for Django 1.9+ Nov 19, 2015
@@ -146,7 +152,11 @@ def _get_reverse_relationships(opts):
)

# Deal with reverse many-to-many relationships.
for relation in opts.get_all_related_many_to_many_objects():
if django.VERSION < (1, 9):
Copy link
Member

@tomchristie tomchristie Nov 19, 2015

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This sort of version-branching code should go into combat.py

We'll want eg a get_all_related_objects(opt) function, and a get_all_related_many_to_many_objects(opt) function.

Looking good tho!

Copy link
Contributor Author

@andreif andreif Nov 19, 2015

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tomchristie Yeah, I started so, but then decided to move it to the only place where it's used and there are already some compat things in the method. Do you want to move all compat-related things to compat.py or just the latest addition?

Copy link
Contributor Author

@andreif andreif Nov 19, 2015

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's probably better to use django version check instead of getattr. What do you think, should I change it?

Copy link
Member

@tomchristie tomchristie Nov 19, 2015

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you want to move all compat-related things to compat.py or just the latest addition?

Just stuff that has a version switch.

It's probably better to use django version check instead of getattr.

Agree. The version check is fine.

Copy link
Contributor Author

@andreif andreif Nov 19, 2015

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tomchristie With version check I meant the lines which are already there, e.g.

related = getattr(relation, 'related_model', relation.model)

Do you prefer to move them as well e.g. related_model(opts)?

Copy link
Member

@tomchristie tomchristie Nov 19, 2015

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If there's a newer 1.9 API that we should be using instead then yes. Otherwise no.

@andreif andreif force-pushed the fix/deprecated-related branch from 9b905b4 to 2acc6a7 Compare Nov 19, 2015
@andreif
Copy link
Contributor Author

andreif commented Nov 19, 2015

@tomchristie done.

@tomchristie tomchristie added this to the 3.3.2 Release milestone Nov 19, 2015
@tomchristie
Copy link
Member

tomchristie commented Nov 19, 2015

Perfect!

tomchristie added a commit that referenced this pull request Nov 19, 2015
Fix #3252 -- Use related_objects api for Django 1.9+
@tomchristie tomchristie merged commit f30f25f into encode:master Nov 19, 2015
@tomchristie tomchristie changed the title Fix #3252 -- Use related_objects api for Django 1.9+ Use related_objects api for Django 1.9+ Nov 19, 2015
@andreif andreif deleted the fix/deprecated-related branch Nov 19, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants