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
Fixed #24716 -- Deprecated Field._get_val_from_obj() #4562
Conversation
It doesn't seem best to me to recommend using There is also the issue that if a custom field is overriding Please see the Deprecating a Feature checklist. In particular, we need documentation. A Trac ticket should also be created to track the change. Thanks. |
I fail to see how it makes anything less extensible -- I wanted to remove As far as the discrepancy between the documentation and the implementation goes, Trac ticket #24716 |
b15af12
to
6654cc5
Compare
Here are examples of people overriding https://github.com/search?utf8=%E2%9C%93&q=%22def+_get_val_from_obj%22&type=Code&ref=searchresults |
I took a quick browse through the first page of results, they're all identical, copy_pasted from Whether the "gains" are clear enough, I can't say. As it stands there are two identical methods which both do exactly the same (useless and redundant) thing, one of which is (unfortunately) named as a private method and should be removed. The migration path is simple -- rename all calls to |
And just looked through the next five pages of results. All exactly the same c+v code. Why the hell do people do that? Argh. |
@@ -58,6 +58,8 @@ details on these changes. | |||
* The ``django.template.loaders.base.Loader.__call__()`` method will be | |||
removed. | |||
|
|||
* ``Field._get_val_from_obj()`` will be renamed to ``Field.value_from_object()`` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
will be removed
I think using |
I understand that, but internal consistency and readability is important too. 99% of all field values are fetched using (which incidentally, is the reason I wanted to change it in the first place -- readability). And what does it matter if the user c+vs the
"Get the attribute from the model, using the |
I guess I would be less averse if |
The method duplicates the functionality of `Field.value_from_object` and has the additional downside of being a privately named public API method. All usage of the method in django.* libraries have been replaced with a call to getattr, to reduce the overhead of an additional, unecessary function call.
6654cc5
to
06d1ab8
Compare
I made the suggested documentation changes and documented |
The method duplicates the functionality of
Field.value_from_object
and has the additional downside of being a privately named public
API method.
All usage of the method in django.* libraries have been replaced
with a call to getattr, to reduce the overhead of an additional,
unecessary function call.
No unittests are added, since this is just the removal of a single method,
which was already amply tested by the serialization tests.