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

Don't proxy special methods to model in ProxyModel.__getattr__ #108

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Commits on Oct 19, 2024

  1. 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 clokep#107
    optiz0r committed Oct 19, 2024
    Configuration menu
    Copy the full SHA
    ee514e6 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    66bea0c View commit details
    Browse the repository at this point in the history