#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:  Unreviewed
    Has patch:  0              |      Needs documentation:  0
  Needs tests:  0              |  Patch needs improvement:  0
Easy pickings:  0              |                    UI/UX:  0
-------------------------------+-----------------------------------------
Changes (by Baha Sdtbekov):

 * owner:  nobody => Baha Sdtbekov
 * status:  new => assigned


Old description:

> I have two models, `Question` and `Choice`.  And if I write `list_display
> = ["choice"]` in `QuestionAdmin`, I get no errors.
> But when I visit `/admin/polls/question/`, the following trace is
> returned:
>
> {{{
> Internal Server Error: /admin/polls/question/
> Traceback (most recent call last):
>   File "/some/path/django/contrib/admin/utils.py", line 334, in
> label_for_field
>     field = _get_non_gfk_field(model._meta, name)
>   File "/some/path/django/contrib/admin/utils.py", line 310, in
> _get_non_gfk_field
>     raise FieldDoesNotExist()
> django.core.exceptions.FieldDoesNotExist
>
> During handling of the above exception, another exception occurred:
>
> Traceback (most recent call last):
>   File "/some/path/django/core/handlers/exception.py", line 55, in inner
>     response = get_response(request)
>   File "/some/path/django/core/handlers/base.py", line 220, in
> _get_response
>     response = response.render()
>   File "/some/path/django/template/response.py", line 111, in render
>     self.content = self.rendered_content
>   File "/some/path/django/template/response.py", line 89, in
> rendered_content
>     return template.render(context, self._request)
>   File "/some/path/django/template/backends/django.py", line 61, in
> render
>     return self.template.render(context)
>   File "/some/path/django/template/base.py", line 175, in render
>     return self._render(context)
>   File "/some/path/django/template/base.py", line 167, in _render
>     return self.nodelist.render(context)
>   File "/some/path/django/template/base.py", line 1005, in render
>     return SafeString("".join([node.render_annotated(context) for node in
> self]))
>   File "/some/path/django/template/base.py", line 1005, in <listcomp>
>     return SafeString("".join([node.render_annotated(context) for node in
> self]))
>   File "/some/path/django/template/base.py", line 966, in
> render_annotated
>     return self.render(context)
>   File "/some/path/django/template/loader_tags.py", line 157, in render
>     return compiled_parent._render(context)
>   File "/some/path/django/template/base.py", line 167, in _render
>     return self.nodelist.render(context)
>   File "/some/path/django/template/base.py", line 1005, in render
>     return SafeString("".join([node.render_annotated(context) for node in
> self]))
>   File "/some/path/django/template/base.py", line 1005, in <listcomp>
>     return SafeString("".join([node.render_annotated(context) for node in
> self]))
>   File "/some/path/django/template/base.py", line 966, in
> render_annotated
>     return self.render(context)
>   File "/some/path/django/template/loader_tags.py", line 157, in render
>     return compiled_parent._render(context)
>   File "/some/path/django/template/base.py", line 167, in _render
>     return self.nodelist.render(context)
>   File "/some/path/django/template/base.py", line 1005, in render
>     return SafeString("".join([node.render_annotated(context) for node in
> self]))
>   File "/some/path/django/template/base.py", line 1005, in <listcomp>
>     return SafeString("".join([node.render_annotated(context) for node in
> self]))
>   File "/some/path/django/template/base.py", line 966, in
> render_annotated
>     return self.render(context)
>   File "/some/path/django/template/loader_tags.py", line 63, in render
>     result = block.nodelist.render(context)
>   File "/some/path/django/template/base.py", line 1005, in render
>     return SafeString("".join([node.render_annotated(context) for node in
> self]))
>   File "/some/path/django/template/base.py", line 1005, in <listcomp>
>     return SafeString("".join([node.render_annotated(context) for node in
> self]))
>   File "/some/path/django/template/base.py", line 966, in
> render_annotated
>     return self.render(context)
>   File "/some/path/django/template/loader_tags.py", line 63, in render
>     result = block.nodelist.render(context)
>   File "/some/path/django/template/base.py", line 1005, in render
>     return SafeString("".join([node.render_annotated(context) for node in
> self]))
>   File "/some/path/django/template/base.py", line 1005, in <listcomp>
>     return SafeString("".join([node.render_annotated(context) for node in
> self]))
>   File "/some/path/django/template/base.py", line 966, in
> render_annotated
>     return self.render(context)
>   File "/some/path/django/contrib/admin/templatetags/base.py", line 45,
> in render
>     return super().render(context)
>   File "/some/path/django/template/library.py", line 258, in render
>     _dict = self.func(*resolved_args, **resolved_kwargs)
>   File "/some/path/django/contrib/admin/templatetags/admin_list.py", line
> 326, in result_list
>     headers = list(result_headers(cl))
>   File "/some/path/django/contrib/admin/templatetags/admin_list.py", line
> 90, in result_headers
>     text, attr = label_for_field(
>   File "/some/path/django/contrib/admin/utils.py", line 362, in
> label_for_field
>     raise AttributeError(message)
> AttributeError: Unable to lookup 'choice' on Question or QuestionAdmin
> [24/Apr/2023 15:43:32] "GET /admin/polls/question/ HTTP/1.1" 500 349913
> }}}
>
> I suggest that error E108 be updated to cover this case as well

New description:

 I have two models, `Question` and `Choice`.  And if I write `list_display
 = ["choice"]` in `QuestionAdmin`, I get no errors.
 But when I visit `/admin/polls/question/`, the following trace is
 returned:

 {{{
 Internal Server Error: /admin/polls/question/
 Traceback (most recent call last):
   File "/some/path/django/contrib/admin/utils.py", line 334, in
 label_for_field
     field = _get_non_gfk_field(model._meta, name)
   File "/some/path/django/contrib/admin/utils.py", line 310, in
 _get_non_gfk_field
     raise FieldDoesNotExist()
 django.core.exceptions.FieldDoesNotExist

 During handling of the above exception, another exception occurred:

 Traceback (most recent call last):
   File "/some/path/django/core/handlers/exception.py", line 55, in inner
     response = get_response(request)
   File "/some/path/django/core/handlers/base.py", line 220, in
 _get_response
     response = response.render()
   File "/some/path/django/template/response.py", line 111, in render
     self.content = self.rendered_content
   File "/some/path/django/template/response.py", line 89, in
 rendered_content
     return template.render(context, self._request)
   File "/some/path/django/template/backends/django.py", line 61, in render
     return self.template.render(context)
   File "/some/path/django/template/base.py", line 175, in render
     return self._render(context)
   File "/some/path/django/template/base.py", line 167, in _render
     return self.nodelist.render(context)
   File "/some/path/django/template/base.py", line 1005, in render
     return SafeString("".join([node.render_annotated(context) for node in
 self]))
   File "/some/path/django/template/base.py", line 1005, in <listcomp>
     return SafeString("".join([node.render_annotated(context) for node in
 self]))
   File "/some/path/django/template/base.py", line 966, in render_annotated
     return self.render(context)
   File "/some/path/django/template/loader_tags.py", line 157, in render
     return compiled_parent._render(context)
   File "/some/path/django/template/base.py", line 167, in _render
     return self.nodelist.render(context)
   File "/some/path/django/template/base.py", line 1005, in render
     return SafeString("".join([node.render_annotated(context) for node in
 self]))
   File "/some/path/django/template/base.py", line 1005, in <listcomp>
     return SafeString("".join([node.render_annotated(context) for node in
 self]))
   File "/some/path/django/template/base.py", line 966, in render_annotated
     return self.render(context)
   File "/some/path/django/template/loader_tags.py", line 157, in render
     return compiled_parent._render(context)
   File "/some/path/django/template/base.py", line 167, in _render
     return self.nodelist.render(context)
   File "/some/path/django/template/base.py", line 1005, in render
     return SafeString("".join([node.render_annotated(context) for node in
 self]))
   File "/some/path/django/template/base.py", line 1005, in <listcomp>
     return SafeString("".join([node.render_annotated(context) for node in
 self]))
   File "/some/path/django/template/base.py", line 966, in render_annotated
     return self.render(context)
   File "/some/path/django/template/loader_tags.py", line 63, in render
     result = block.nodelist.render(context)
   File "/some/path/django/template/base.py", line 1005, in render
     return SafeString("".join([node.render_annotated(context) for node in
 self]))
   File "/some/path/django/template/base.py", line 1005, in <listcomp>
     return SafeString("".join([node.render_annotated(context) for node in
 self]))
   File "/some/path/django/template/base.py", line 966, in render_annotated
     return self.render(context)
   File "/some/path/django/template/loader_tags.py", line 63, in render
     result = block.nodelist.render(context)
   File "/some/path/django/template/base.py", line 1005, in render
     return SafeString("".join([node.render_annotated(context) for node in
 self]))
   File "/some/path/django/template/base.py", line 1005, in <listcomp>
     return SafeString("".join([node.render_annotated(context) for node in
 self]))
   File "/some/path/django/template/base.py", line 966, in render_annotated
     return self.render(context)
   File "/some/path/django/contrib/admin/templatetags/base.py", line 45, in
 render
     return super().render(context)
   File "/some/path/django/template/library.py", line 258, in render
     _dict = self.func(*resolved_args, **resolved_kwargs)
   File "/some/path/django/contrib/admin/templatetags/admin_list.py", line
 326, in result_list
     headers = list(result_headers(cl))
   File "/some/path/django/contrib/admin/templatetags/admin_list.py", line
 90, in result_headers
     text, attr = label_for_field(
   File "/some/path/django/contrib/admin/utils.py", line 362, in
 label_for_field
     raise AttributeError(message)
 AttributeError: Unable to lookup 'choice' on Question or QuestionAdmin
 [24/Apr/2023 15:43:32] "GET /admin/polls/question/ HTTP/1.1" 500 349913
 }}}

 I suggest that error E108 be updated to cover this case as well

 For reproduce see [https://github.com/Bakdolot/django_34513 github]

--

-- 
Ticket URL: <https://code.djangoproject.com/ticket/34513#comment:1>
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/01070187b3fe6960-15b188d1-6929-4ff0-a6b8-acc87641fcf7-000000%40eu-central-1.amazonses.com.

Reply via email to