Commit db0f571
committed
Don't proxy special methods to model in ProxyModel.__getattr__
ProxyModel.__getattr__ previously proxied all attribute lookups to the
model class, but some third party libraries (e.g. DRF) will make calls which
should be handled by the ProxyModel instance rather than the proxied class.
For example, deepcopy invokes `__reduce_ex__()` that pickles an instance and
needs access to `__getstate__()` which does note exist on a class.
Proxying calls to the model is required in some cases, e.g. for access to _meta.
This change avoids proxying any special methods (those starting with `__`) to
the model. Fixes DRF schema generation for a serializer which contains a
field using QuerySetSequence.
Adds test cases to verify behaviour of method proxying.
Fixes #1071 parent 3fe2994 commit db0f571
2 files changed
+40
-4
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
493 | 493 | | |
494 | 494 | | |
495 | 495 | | |
496 | | - | |
| 496 | + | |
| 497 | + | |
| 498 | + | |
| 499 | + | |
| 500 | + | |
497 | 501 | | |
498 | 502 | | |
499 | 503 | | |
| |||
846 | 850 | | |
847 | 851 | | |
848 | 852 | | |
849 | | - | |
850 | | - | |
851 | | - | |
| 853 | + | |
852 | 854 | | |
853 | 855 | | |
854 | 856 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
0 commit comments