Ticket #10953: proxy-proxy.diff

File proxy-proxy.diff, 1.8 KB (added by Alex, 6 years ago)
  • django/db/models/base.py

    diff --git a/django/db/models/base.py b/django/db/models/base.py
    index 05cd0d9..3a3fbf1 100644
    a b class ModelBase(type): 
    116116                    new_class._meta.local_many_to_many):
    117117                raise FieldError("Proxy model '%s' contains model fields."
    118118                        % name)
     119            while base._meta.proxy:
     120                base = base._meta.proxy_for_model
    119121            new_class._meta.setup_proxy(base)
    120122
    121123        # Do the appropriate setup for any model parents.
    class ModelBase(type): 
    123125                if isinstance(f, OneToOneField)])
    124126
    125127        for base in parents:
     128            original_base = base
    126129            if not hasattr(base, '_meta'):
    127130                # Things without _meta aren't functional models, so they're
    128131                # uninteresting parents.
    class ModelBase(type): 
    167170            # Proxy models inherit the non-abstract managers from their base,
    168171            # unless they have redefined any of them.
    169172            if is_proxy:
    170                 new_class.copy_managers(base._meta.concrete_managers)
     173                new_class.copy_managers(original_base._meta.concrete_managers)
    171174
    172175            # Inherit virtual fields (like GenericForeignKey) from the parent
    173176            # class
  • tests/modeltests/proxy_models/models.py

    diff --git a/tests/modeltests/proxy_models/models.py b/tests/modeltests/proxy_models/models.py
    index ab38112..1c380e8 100644
    a b FieldError: Proxy model 'NoNewFields' contains model fields. 
    178178>>> ctype = ContentType.objects.get_for_model
    179179>>> ctype(Person) is ctype(OtherPerson)
    180180True
    181 """}
    182 
    183181
     182>>> MyPersonProxy.objects.all()
     183[<MyPersonProxy: barney>, <MyPersonProxy: fred>]
     184"""}
Back to Top