Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

[1.6.x] Revert "Fixed #18491 -- deleting a proxy doesn't show warning…

… about cascade deletes"

This reverts commit 2b48fcc.

It introduced a regression (#20777) which we can't easily fix in 1.6.
  • Loading branch information...
commit c769c266017c9a527444f8f026c7a76b394d0412 1 parent 9199346
Tim Graham timgraham authored
3  django/contrib/admin/util.py
View
@@ -155,9 +155,6 @@ def collect(self, objs, source_attr=None, **kwargs):
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)
24 tests/proxy_models/fixtures/myhorses.json
View
@@ -1,24 +0,0 @@
-[
- {
- "pk": 100,
- "model": "proxy_models.BaseUser",
- "fields": {
- "name": "Django Pony"
- }
- },
- {
- "pk": 100,
- "model": "proxy_models.TrackerUser",
- "fields": {
- "status": "emperor"
- }
- },
- {
- "pk": 100,
- "model": "proxy_models.Issue",
- "fields": {
- "summary": "Pony's Issue",
- "assignee": 100
- }
- }
-]
22 tests/proxy_models/tests.py
View
@@ -2,7 +2,6 @@
import copy
from django.conf import settings
-from django.contrib import admin
from django.contrib.contenttypes.models import ContentType
from django.core import management
from django.core.exceptions import FieldError
@@ -15,7 +14,7 @@
from .models import (MyPerson, Person, StatusPerson, LowerStatusPerson,
MyPersonProxy, Abstract, OtherPerson, User, UserProxy, UserProxyProxy,
Country, State, StateProxy, TrackerUser, BaseUser, Bug, ProxyTrackerUser,
- Improvement, ProxyProxyBug, ProxyBug, ProxyImprovement, Issue)
+ Improvement, ProxyProxyBug, ProxyBug, ProxyImprovement)
class ProxyModelTests(TestCase):
@@ -361,22 +360,3 @@ def test_proxy_load_from_fixture(self):
management.call_command('loaddata', 'mypeople.json', verbosity=0)
p = MyPerson.objects.get(pk=100)
self.assertEqual(p.name, 'Elvis Presley')
-
-
-class ProxyModelAdminTests(TestCase):
- fixtures = ['myhorses']
-
- def test_cascade_delete_proxy_model_admin_warning(self):
- """
- Test if admin gives warning about cascade deleting models referenced
- to concrete model by deleting proxy object.
- """
- tracker_user = TrackerUser.objects.all()[0]
- base_user = BaseUser.objects.all()[0]
- issue = Issue.objects.all()[0]
- with self.assertNumQueries(7):
- collector = admin.util.NestedObjects('default')
- collector.collect(ProxyTrackerUser.objects.all())
- self.assertTrue(tracker_user in collector.edges.get(None, ()))
- self.assertTrue(base_user in collector.edges.get(None, ()))
- self.assertTrue(issue in collector.edges.get(tracker_user, ()))
Please sign in to comment.
Something went wrong with that request. Please try again.