Code

Ticket #4810: 4810.diff

File 4810.diff, 1.3 KB (added by ubernostrum, 7 years ago)

Patch implementing the check with isinstance() instead of issubclass()

Line 
1Index: django/contrib/admin/sites.py
2===================================================================
3--- django/contrib/admin/sites.py       (revision 5637)
4+++ django/contrib/admin/sites.py       (working copy)
5@@ -1,7 +1,7 @@
6 from django import http, template
7 from django.contrib.admin import ModelAdmin
8 from django.contrib.auth import authenticate, login
9-from django.db.models import Model
10+from django.db.models.base import ModelBase
11 from django.shortcuts import render_to_response
12 from django.utils.text import capfirst
13 from django.utils.translation import ugettext_lazy, ugettext as _
14@@ -69,7 +69,7 @@
15         """
16         admin_class = admin_class or ModelAdmin
17         # TODO: Handle options
18-        if issubclass(model_or_iterable, Model):
19+        if isinstance(model_or_iterable, ModelBase):
20             model_or_iterable = [model_or_iterable]
21         for model in model_or_iterable:
22             if model in self._registry:
23@@ -82,7 +82,7 @@
24 
25         If a model isn't already registered, this will raise NotRegistered.
26         """
27-        if issubclass(model_or_iterable, Model):
28+        if isinstance(model_or_iterable, ModelBase):
29             model_or_iterable = [model_or_iterable]
30         for model in model_or_iterable:
31             if model not in self._registry: