#34513: Error E108 does not cover some cases
-------------------------------+-----------------------------------------
Reporter: Baha Sdtbekov | Owner: Baha Sdtbekov
Type: Bug | Status: assigned
Component: contrib.admin | Version: 4.2
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------+-----------------------------------------
Comment (by David Sanders):
fyi potential quick fix, this will cause it to start raising E108 errors.
this is just a demo of where to look. One possibility we could abandon
using `get_field()` and refer to `_meta.fields` instead? 🤔… though that
would mean the E109 check below this would no longer work.
{{{#!diff
--- a/django/contrib/admin/checks.py
+++ b/django/contrib/admin/checks.py
@@ -9,6 +9,7 @@ from django.core.exceptions import FieldDoesNotExist
from django.db import models
from django.db.models.constants import LOOKUP_SEP
from django.db.models.expressions import Combinable
+from django.db.models.fields.reverse_related import ManyToOneRel
from django.forms.models import BaseModelForm, BaseModelFormSet,
_get_foreign_key
from django.template import engines
from django.template.backends.django import DjangoTemplates
@@ -897,6 +898,8 @@ class ModelAdminChecks(BaseModelAdminChecks):
return []
try:
field = obj.model._meta.get_field(item)
+ if isinstance(field, ManyToOneRel):
+ raise FieldDoesNotExist
except FieldDoesNotExist:
try:
field = getattr(obj.model, item)
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/34513#comment:4>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/01070187b4312d6f-cb75fdf1-b1f0-4f26-9161-29cbf7d46964-000000%40eu-central-1.amazonses.com.