Commit 3844089e authored by Anssi Kääriäinen's avatar Anssi Kääriäinen
Browse files

Fixed #20777 -- Admin proxy model deletion regression

Added proxy_models tests by Harm Geerts <github@geertswei.nl>.
parent 4668c142
Loading
Loading
Loading
Loading
+0 −3
Original line number Diff line number Diff line
@@ -155,9 +155,6 @@ class NestedObjects(Collector):
            if source_attr:
                self.add_edge(getattr(obj, source_attr), obj)
            else:
                if obj._meta.proxy:
                    # Take concrete model's instance to avoid mismatch in edges
                    obj = obj._meta.concrete_model(pk=obj.pk)
                self.add_edge(None, obj)
        try:
            return super(NestedObjects, self).collect(objs, source_attr=source_attr, **kwargs)
+3 −3
Original line number Diff line number Diff line
@@ -500,9 +500,9 @@ using ``__str__()`` like this::
.. method:: Model.__eq__()

The equality method is defined such that instances with the same primary
key value and the same concrete class are considered equal. The term
concrete class means proxy model's first non-proxy parent or the class
itself if it isn't a proxy class.
key value and the same concrete class are considered equal. For proxy
models, concrete class is defined as the model's first non-proxy parent;
for all other models it is simply the model's class.

For example::

+6 −0
Original line number Diff line number Diff line
from django.contrib import admin

from .models import TrackerUser, ProxyTrackerUser

admin.site.register(TrackerUser)
admin.site.register(ProxyTrackerUser)
+19 −1
Original line number Diff line number Diff line
[
    {
        "pk": 100,
        "model": "auth.user",
        "fields": {
            "username": "super",
            "first_name": "Super",
            "last_name": "User",
            "is_active": true,
            "is_superuser": true,
            "is_staff": true,
            "last_login": "2007-05-30 13:20:10",
            "groups": [],
            "user_permissions": [],
            "password": "sha1$995a3$6011485ea3834267d719b4c801409b8b1ddd0158",
            "email": "super@example.com",
            "date_joined": "2007-05-30 13:20:10"
        }
    },
    {
        "pk": 100,
        "model": "proxy_models.BaseUser",
+5 −1
Original line number Diff line number Diff line
@@ -117,9 +117,13 @@ class StateProxy(State):

# Proxy models still works with filters (on related fields)
# and select_related, even when mixed with model inheritance
@python_2_unicode_compatible
class BaseUser(models.Model):
    name = models.CharField(max_length=255)

    def __str__(self):
        return ':'.join((self.__class__.__name__, self.name,))

class TrackerUser(BaseUser):
    status = models.CharField(max_length=50)

Loading