#35979: Empty form ErrorList display as square brackets "[]"
-------------------------------------+-------------------------------------
     Reporter:  Benjamin Mampaey     |                     Type:
                                     |  Uncategorized
       Status:  new                  |                Component:  Forms
      Version:  5.1                  |                 Severity:  Normal
     Keywords:                       |             Triage Stage:
                                     |  Unreviewed
    Has patch:  0                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  1
-------------------------------------+-------------------------------------
 This is probably not a Django bug, it does not appear when running Django
 with manage.py runserver, but appears when running django with apache2 and
 some versions of mod_wsgi. I believe it should be made public so that if
 other people stumble on that problem, they know how to fix it.

 In the admin templates, when forms are displayed, if there are no errors,
 there is a pair of square brackets above the label. For example in the
 login form, it shows a pair of square brackets above the label "Username".

 From what I could find, mod_wsgi uses sub interpreters, and in version
 below 2.12.5 there is a bug where the MRO for !__str!__ is not properly
 done https://mliezun.github.io/2024/08/19/cpython-subinterpreters.html.

 In the admin template, form errors are displayed using the !__str!__
 method, for example in the login template, for the Username field :

 {{{
   <div class="form-row">
     {{ form.username.errors }}
     {{ form.username.label_tag }} {{ form.username }}
   </div>
 }}}

 And the definition of ErrorList is

 {{{
 class ErrorList(UserList, list, RenderableErrorMixin)
 }}}

 Thus, because of the bug, when calling the !__str!__ method of ErrorList,
 instead of calling the !__str!__ method of RenderableErrorMixin, that
 returns an empty string '', it is the !__str!__ method of list that is
 called that returns '[]'.
-- 
Ticket URL: <https://code.djangoproject.com/ticket/35979>
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 visit 
https://groups.google.com/d/msgid/django-updates/010701939c22d7ea-09ef9aec-6750-4c90-b33f-baaad6199d18-000000%40eu-central-1.amazonses.com.

Reply via email to