#33729: [BUG] AutocompleteSelect widget broken after moving from django 2.2 to
django 3.2
------------------------------------+--------------------------------------
     Reporter:  exo                 |                    Owner:  nobody
         Type:  Bug                 |                   Status:  closed
    Component:  contrib.admin       |                  Version:  3.2
     Severity:  Normal              |               Resolution:  invalid
     Keywords:  AutocompleteSelect  |             Triage Stage:  Unreviewed
    Has patch:  0                   |      Needs documentation:  0
  Needs tests:  0                   |  Patch needs improvement:  0
Easy pickings:  0                   |                    UI/UX:  0
------------------------------------+--------------------------------------
Changes (by Mariusz Felisiak):

 * status:  new => closed
 * resolution:   => invalid


Comment:

 Replying to [ticket:33729 exo]:
 > Hello :) After upgrading `Django` version to `3.2`, widget
 `AutocompleteSelect` that I use in `django` admin panel (to have a drop-
 down from which I can choose an object) **is broken**.
 >
 > The error I see is
 > {{{
 >     AttributeError at /admin/question/
 >     'QuerySet' object has no attribute 'name'
 >
 >     Request Method:   GET
 >     Request URL:      http://localhost:8000/admin/question/
 >     Django Version:   3.2.13
 >     Exception Type:   AttributeError
 >     Exception Value:
 >     'QuerySet' object has no attribute 'name'
 >     Exception Location:       /home/django-app/env/lib/python3.8/site-
 packages/django/contrib/admin/widgets.py, line 412, in build_attrs
 >     Python Executable:        /home/django-app/env/bin/python3
 >     Python Version:   3.8.10
 >     Python Path:
 >     ['/home/django-app/testsite',
 >      '/usr/lib/python38.zip',
 >      '/usr/lib/python3.8',
 >      '/usr/lib/python3.8/lib-dynload',
 >      '/home/django-app/env/lib/python3.8/site-packages']
 >     Server time:      Fri, 20 May 2022 10:13:27 +0000
 >     Error during template rendering
 >     In template /home/django-
 app/testsite/polls/templates/admin/question_export.html, error at line 18
 >
 >     'QuerySet' object has no attribute 'name'
 >     11
 >     12        {% block content %}
 >     13            <div id="content-main">
 >     14              <p>Select question to export:</p>
 >     15                <form method="post" enctype="multipart/form-data">
 >     16                    {% csrf_token %}
 >     17                    <table>
 >     18                        {{form.as_table}}
 >     19                    </table>
 >     20                    <div class="submit-row">
 >     21                        <input type="submit" value="Export
 Question" />
 >     22                    </div>
 >     23                </form>
 >     24            </div>
 >     25            {{form.media}}
 >     26        {% endblock %}
 >     27
 > }}}
 > `AutocompleteSelect` inherits from `AutocompleteMixin`
 >
 > When I compare `AutocompleteMixin` for `django 3.2` and `django 2.2`
 >
 
https://github.com/django/django/blob/3.2.13/django/contrib/admin/widgets.py#L410-L412
 >
 
https://github.com/django/django/blob/2.2.7/django/contrib/admin/widgets.py#L411
 >
 > I see that they added new attributes
 > {{{
 >     'data-app-label': self.field.model._meta.app_label,
 >     'data-model-name': self.field.model._meta.model_name,
 >     'data-field-name': self.field.name,
 > }}}
 > in `django 3.2`
 > but there is no `name` on `self.field` and probably that's why I get
 this error.

 `self.field` should be a `Field` instance not a `QuerySet`. Moreover
 autocomplete works for me. It looks like an issue in 3rd-party package
 (see similar reports for autocomplete e.g. #32619 and #32659).

 Closing per TicketClosingReasons/UseSupportChannels.

-- 
Ticket URL: <https://code.djangoproject.com/ticket/33729#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/01070180e213d6db-e40a382f-fa2d-4927-ab82-1abacb9bf80b-000000%40eu-central-1.amazonses.com.

Reply via email to