I have the following problem when using autocomplete_fields field under django3.2

Viewed 994

The following problems will occur:

screenshot

When I use the version below django3.2, everything is normal. I don't know if this is my problem?

And django will raise the following error:

    During handling of the above exception, another exception occurred:
Traceback (most recent call last):
    File "C:\Users\admin\.virtualenvs\easyshow\lib\site-packages\django\contrib\admin\views\autocomplete.py", line 61, in process_request
        app_label = request.GET['app_label']
    File "C:\Users\admin\.virtualenvs\easyshow\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\admin\.virtualenvs\easyshow\lib\site-packages\django\core\handlers\exception.py", line 47, in inner
        response = get_response(request)
    File "C:\Users\admin\.virtualenvs\easyshow\lib\site-packages\django\core\handlers\base.py", line 181, in _get_response
        response = wrapped_callback(request, *callback_args, **callback_kwargs)
    File "C:\Users\admin\.virtualenvs\easyshow\lib\site-packages\django\contrib\admin\sites.py", line 250, in wrapper
        return self.admin_view(view, cacheable)(*args, **kwargs)
    File "C:\Users\admin\.virtualenvs\easyshow\lib\site-packages\django\utils\decorators.py", line 130, in _wrapped_view
        response = view_func(request, *args, **kwargs)
    File "C:\Users\admin\.virtualenvs\easyshow\lib\site-packages\django\views\decorators\cache.py", line 44, in _wrapped_view_func
        response = view_func(request, *args, **kwargs)
    File "C:\Users\admin\.virtualenvs\easyshow\lib\site-packages\django\contrib\admin\sites.py", line 232, in inner
        return view(request, *args, **kwargs)
    File "C:\Users\admin\.virtualenvs\easyshow\lib\site-packages\django\contrib\admin\sites.py", line 417, in autocomplete_view
        return AutocompleteJsonView.as_view(admin_site=self)(request)
    File "C:\Users\admin\.virtualenvs\easyshow\lib\site-packages\django\views\generic\base.py", line 70, in view
        return self.dispatch(request, *args, **kwargs)
    File "C:\Users\admin\.virtualenvs\easyshow\lib\site-packages\django\views\generic\base.py", line 98, in dispatch
        return handler(request, *args, **kwargs)
    File "C:\Users\admin\.virtualenvs\easyshow\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\admin\.virtualenvs\easyshow\lib\site-packages\django\contrib\admin\views\autocomplete.py", line 65, in process_request
        raise PermissionDenied from e

django.core.exceptions.PermissionDenied
2 Answers

It is a caching problem. Go to your django shell: python manage.py shell

Then

from django.core.cache import cache
cache.clear()

Refresh your form on the browser and you're good to go!

Related