﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
33261	Autocomplete field triggers a PermissionDenied error	Gianluca Romanin	nobody	"I added to my code a autocomplete field in the ModelAdmin class of a model name UserData
Code is pretty simple:

{{{
@admin.register(UserData)
class UserDataAdmin(admin.ModelAdmin):
    list_display = (""fiscal_code"", ""company"", ""surname"", ""name"")
    fields = [""company"", ""name"", ""surname"", ""fiscal_code"", ""address"", ""identity_document""]
    # FIXME: autocomplete does not work in Django 3.2.X. Downgraded to 3.1.X
    autocomplete_fields = [""company""]
}}}

The interface shows ""The results could not be loaded"" and console shows the following errors:


{{{
Traceback (most recent call last):
  File ""C:\Users\username\AppData\Local\pypoetry\Cache\virtualenvs\kdocweb-1PRTDUa5-py3.9\lib\site-packages\django\contrib\admin\views\autocomplete.py"", line 61, in process_request
    app_label = request.GET['app_label']
  File ""C:\Users\username\AppData\Local\pypoetry\Cache\virtualenvs\kdocweb-1PRTDUa5-py3.9\lib\site-packages\django\utils\datastructures.py"", line 78, in __getitem__
    raise MultiValueDictKeyError(key)
django.utils.datastructures.MultiValueDictKeyError: 'app_label'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File ""C:\Users\username\AppData\Local\pypoetry\Cache\virtualenvs\kdocweb-1PRTDUa5-py3.9\lib\site-packages\django\core\handlers\exception.py"", line 47, in inner
    response = get_response(request)
  File ""C:\Users\username\AppData\Local\pypoetry\Cache\virtualenvs\kdocweb-1PRTDUa5-py3.9\lib\site-packages\django\core\handlers\base.py"", line 181, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File ""C:\Users\username\AppData\Local\pypoetry\Cache\virtualenvs\kdocweb-1PRTDUa5-py3.9\lib\site-packages\django\contrib\admin\sites.py"", line 250, in wrapper
    return self.admin_view(view, cacheable)(*args, **kwargs)
  File ""C:\Users\username\AppData\Local\pypoetry\Cache\virtualenvs\kdocweb-1PRTDUa5-py3.9\lib\site-packages\django\utils\decorators.py"", line 130, in _wrapped_view
    response = view_func(request, *args, **kwargs)
  File ""C:\Users\username\AppData\Local\pypoetry\Cache\virtualenvs\kdocweb-1PRTDUa5-py3.9\lib\site-packages\django\views\decorators\cache.py"", line 44, in _wrapped_view_func
    response = view_func(request, *args, **kwargs)
  File ""C:\Users\username\AppData\Local\pypoetry\Cache\virtualenvs\kdocweb-1PRTDUa5-py3.9\lib\site-packages\django\contrib\admin\sites.py"", line 232, in inner
    return view(request, *args, **kwargs)
  File ""C:\Users\username\AppData\Local\pypoetry\Cache\virtualenvs\kdocweb-1PRTDUa5-py3.9\lib\site-packages\django\contrib\admin\sites.py"", line 417, in autocomplete_view
    return AutocompleteJsonView.as_view(admin_site=self)(request)
  File ""C:\Users\username\AppData\Local\pypoetry\Cache\virtualenvs\kdocweb-1PRTDUa5-py3.9\lib\site-packages\django\views\generic\base.py"", line 70, in view
    return self.dispatch(request, *args, **kwargs)
  File ""C:\Users\username\AppData\Local\pypoetry\Cache\virtualenvs\kdocweb-1PRTDUa5-py3.9\lib\site-packages\django\views\generic\base.py"", line 98, in dispatch
    return handler(request, *args, **kwargs)
  File ""C:\Users\username\AppData\Local\pypoetry\Cache\virtualenvs\kdocweb-1PRTDUa5-py3.9\lib\site-packages\django\contrib\admin\views\autocomplete.py"", line 20, in get
    self.term, self.model_admin, self.source_field, to_field_name = self.process_request(request)
  File ""C:\Users\username\AppData\Local\pypoetry\Cache\virtualenvs\kdocweb-1PRTDUa5-py3.9\lib\site-packages\django\contrib\admin\views\autocomplete.py"", line 65, in process_request
    raise PermissionDenied from e
django.core.exceptions.PermissionDenied
}}}

The issue is the same of ticket [https://code.djangoproject.com/ticket/32659] and it is still not resolved in version 3.2.9.
Downgrading to version 3.1.13 resolves the issue and autocomplete fields work as expected.
The previous ticket was closed with no solution. There is no issue with multiple url definition in my case, downgrading is a workaround but the last LTS version of Django is 3.2.X and here the bug is present.
If the issue is a configuration problem, please give an hint on the solution. 
If not, please manage the ticket accordingly.
"	Bug	closed	contrib.admin	3.2	Normal	duplicate			Unreviewed	0	0	0	0	0	0
