Use related_objects api for Django 1.9+#3656
Conversation
There was a problem hiding this comment.
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!
There was a problem hiding this comment.
@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?
There was a problem hiding this comment.
It's probably better to use django version check instead of getattr. What do you think, should I change it?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
@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)?
There was a problem hiding this comment.
If there's a newer 1.9 API that we should be using instead then yes. Otherwise no.
9b905b4 to
2acc6a7
Compare
|
@tomchristie done. |
|
Perfect! |
Fix #3252 -- Use related_objects api for Django 1.9+
Closes #3252.