Opened 9 months ago
Last modified 9 months ago
#35337 closed Bug
argument of type 'NoneType' is not iterable, when show facets and change_view is overwritten in ModelAdmin — at Version 4
Reported by: | dz | Owned by: | nobody |
---|---|---|---|
Component: | contrib.admin | Version: | 5.0 |
Severity: | Normal | Keywords: | |
Cc: | dz | Triage Stage: | Unreviewed |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description (last modified by )
Hello,
Django==5.0.3
@admin.register(LicitacionItem) class LicitacionItemAdmin(admin.ModelAdmin): list_select_related = ('licitacion', 'categoria', 'proveedor', 'producto', 'licitacion_detalle') raw_id_fields = ('licitacion', 'categoria', 'proveedor', 'producto', 'licitacion_detalle') search_fields = ["CodigoExterno", 'search'] show_facets = admin.ShowFacets.ALLOW list_filter = [ ('licitacion__date', admin.DateFieldListFilter), ('licitacion__FechaCierre', admin.DateFieldListFilter), 'licitacion__CodigoEstado', 'active', 'licitacion_detalle__CodigoTipo', 'licitacion_detalle__Tipo', 'licitacion_detalle__TipoConvocatoria', 'licitacion_detalle__CodigoTipo'] def change_view(self, request, object_id, extra_context=None): self.exclude = ('active', 'analizado', 'touch', 'search') return super(LicitacionItemAdmin, self).change_view(request, object_id, extra_context)
when clicking on an item (enter change view), without activating show facets: there are no errors.
when clicking on an item (enter change view), with show facets activated: argument of type 'NoneType' is not iterable (see attached file with the trace)
By completely removing the change_view function, the error does not occur (even if show facets is activated).
Regards
1 Environment: 2 3 4 Request Method: GET 5 Request URL: http://192.168.101.60/admin/mpublico/licitacionitem/54719/change/?_changelist_filters=_facets%3DTrue 6 7 Django Version: 5.0.3 8 Python Version: 3.10.12 9 Installed Applications: 10 ['django.contrib.admin', 11 'django.contrib.auth', 12 'django.contrib.contenttypes', 13 'django.contrib.sessions', 14 'django.contrib.messages', 15 'django.contrib.staticfiles', 16 'localflavor', 17 'mpublico', 18 'rest_framework', 19 'rest_framework.authtoken', 20 'django_celery_results', 21 'debug_toolbar', 22 'import_export'] 23 Installed Middleware: 24 ['debug_toolbar.middleware.DebugToolbarMiddleware', 25 'django.middleware.security.SecurityMiddleware', 26 'django.contrib.sessions.middleware.SessionMiddleware', 27 'django.middleware.common.CommonMiddleware', 28 'django.middleware.csrf.CsrfViewMiddleware', 29 'django.contrib.auth.middleware.AuthenticationMiddleware', 30 'django.contrib.messages.middleware.MessageMiddleware', 31 'django.middleware.clickjacking.XFrameOptionsMiddleware'] 32 33 34 35 Traceback (most recent call last): 36 File "/home/erp/erp/venv/lib/python3.10/site-packages/django/core/handlers/exception.py", line 55, in inner 37 response = get_response(request) 38 File "/home/erp/erp/venv/lib/python3.10/site-packages/django/core/handlers/base.py", line 197, in _get_response 39 response = wrapped_callback(request, *callback_args, **callback_kwargs) 40 File "/home/erp/erp/venv/lib/python3.10/site-packages/django/contrib/admin/options.py", line 716, in wrapper 41 return self.admin_site.admin_view(view)(*args, **kwargs) 42 File "/home/erp/erp/venv/lib/python3.10/site-packages/django/utils/decorators.py", line 188, in _view_wrapper 43 result = _process_exception(request, e) 44 File "/home/erp/erp/venv/lib/python3.10/site-packages/django/utils/decorators.py", line 186, in _view_wrapper 45 response = view_func(request, *args, **kwargs) 46 File "/home/erp/erp/venv/lib/python3.10/site-packages/django/views/decorators/cache.py", line 80, in _view_wrapper 47 response = view_func(request, *args, **kwargs) 48 File "/home/erp/erp/venv/lib/python3.10/site-packages/django/contrib/admin/sites.py", line 240, in inner 49 return view(request, *args, **kwargs) 50 File "/home/erp/erp/erp/mpublico/admin.py", line 98, in change_view 51 return super(LicitacionItemAdmin, self).change_view(request, object_id, extra_context) 52 File "/home/erp/erp/venv/lib/python3.10/site-packages/django/contrib/admin/options.py", line 1948, in change_view 53 return self.changeform_view(request, object_id, form_url, extra_context) 54 File "/home/erp/erp/venv/lib/python3.10/site-packages/django/utils/decorators.py", line 48, in _wrapper 55 return bound_method(*args, **kwargs) 56 File "/home/erp/erp/venv/lib/python3.10/site-packages/django/utils/decorators.py", line 188, in _view_wrapper 57 result = _process_exception(request, e) 58 File "/home/erp/erp/venv/lib/python3.10/site-packages/django/utils/decorators.py", line 186, in _view_wrapper 59 response = view_func(request, *args, **kwargs) 60 File "/home/erp/erp/venv/lib/python3.10/site-packages/django/contrib/admin/options.py", line 1804, in changeform_view 61 return self._changeform_view(request, object_id, form_url, extra_context) 62 File "/home/erp/erp/venv/lib/python3.10/site-packages/django/contrib/admin/options.py", line 1940, in _changeform_view 63 return self.render_change_form( 64 File "/home/erp/erp/venv/lib/python3.10/site-packages/django/contrib/admin/options.py", line 1294, in render_change_form 65 form_url = add_preserved_filters( 66 File "/home/erp/erp/venv/lib/python3.10/site-packages/django/contrib/admin/templatetags/admin_urls.py", line 37, in add_preserved_filters 67 match_url = "/%s" % unquote(url).partition(get_script_prefix())[2] 68 File "/usr/lib/python3.10/urllib/parse.py", line 667, in unquote 69 if '%' not in string: 70 71 Exception Type: TypeError at /admin/mpublico/licitacionitem/54719/change/ 72 Exception Value: argument of type 'NoneType' is not iterable
Change History (6)
by , 9 months ago
comment:1 by , 9 months ago
Description: | modified (diff) |
---|
comment:2 by , 9 months ago
Description: | modified (diff) |
---|
comment:3 by , 9 months ago
Description: | modified (diff) |
---|
comment:4 by , 9 months ago
Description: | modified (diff) |
---|---|
Type: | Uncategorized → Bug |
Hola! Thank you for your report.
Could you please attach your models (or similar models) that would make this a complete reproducible example?
Thank you!
error trace