Admin error - custom_display_for_JSON.field() got an unexpected keyword argument 'avoid_link'

I migrated the code to django 5.2.4 from 4.2. All ok withe the view and models.

The issue is in admin. The models that have json fields , after I click the app I got this error.

Welcome @colateral !

When requesting assistance with an error message, please copy/paste the complete error message from the server console. Don’t bother pasting the summary information that is provided to the browser.

Side Note: When posting code, templates, error messages, or any other preformatted text here, enclose that text between lines of three
backtick - ` characters. This means you’ll have a line of ```, then the text,
then another line of ```. This forces the forum software to keep that text
properly formatted.

In addition to providing the complete error message, please also post the contents of your INSTALLED_APPS setting and identify the version number of each third-party package in that list.

Installed apps:

‘‘‘ TypeError at /admin/company/address/
’’’ custom_display_for_JSONfield() got an unexpected keyword argument ‘avoid_link’
Request Method: GET
Request URL: http_localhost:8000/admin/company/address/
Django Version: 5.2.5
Exception Type: TypeError
Exception Value:
custom_display_for_JSONfield() got an unexpected keyword argument ‘avoid_link’
Exception Location: D:\Programming@Lumb\fap-new\fap-django.venv\Lib\site-packages\django\contrib\admin\templatetags\admin_list.py, line 246, in items_for_result
Raised during: django.contrib.admin.options.changelist_view
Python Executable: D:\Programming@Lumb\fap-new\fap-django.venv\Scripts\python.exe
Python Version: 3.11.1
Python Path:
[‘D:\Programming\@Lumb\fap-new\fap-django’,
'C:\Program Files\JetBrains\PyCharm ’
‘2025.1.3.1\plugins\python-ce\helpers\pydev’,
'C:\Program Files\JetBrains\PyCharm ’
‘2025.1.3.1\plugins\python-ce\helpers\third_party\thriftpy’,
'C:\Program Files\JetBrains\PyCharm ’
‘2025.1.3.1\plugins\python-ce\helpers\pydev’,
‘D:\Programming\@Lumb\fap-new\fap-django’,
'C:\Program Files\JetBrains\PyCharm ’
‘2025.1.3.1\plugins\python-ce\helpers\pycharm_display’,
‘C:\Users\colateral\AppData\Local\JetBrains\PyCharm2025.1\cythonExtensions’,
'C:\Program Files\JetBrains\PyCharm ’
‘2025.1.3.1\plugins\python\helpers-pro\pydevd_asyncio’,
‘D:\ProgramFiles\python\3_11_1\python311.zip’,
‘D:\ProgramFiles\python\3_11_1\DLLs’,
‘D:\ProgramFiles\python\3_11_1\Lib’,
‘D:\ProgramFiles\python\3_11_1’,
‘D:\Programming\@Lumb\fap-new\fap-django\.venv’,
‘D:\Programming\@Lumb\fap-new\fap-django\.venv\Lib\site-packages’,
‘D:\ProgramFiles\python\3_11_1\Lib\site-packages’,
'C:\Program Files\JetBrains\PyCharm ’
‘2025.1.3.1\plugins\python-ce\helpers\pycharm_matplotlib_backend’,
'C:\Program Files\JetBrains\PyCharm ’
‘2025.1.3.1\plugins\python-ce\helpers\pycharm_plotly_backend’]
Server time: Sat, 09 Aug 2025 09:29:00 +0000
Error during template rendering
In template D:\Programming@Lumb\fap-new\fap-django.venv\Lib\site-packages\django\contrib\admin\templates\admin\change_list.html, error at line 69

custom_display_for_JSONfield() got an unexpected keyword argument ‘avoid_link’
59 {% block search %}{% search_form cl %}{% endblock %}
60 {% block date_hierarchy %}{% if cl.date_hierarchy %}{% date_hierarchy cl %}{% endif %}{% endblock %}
61
62 <form id=“changelist-form” method=“post”{% if cl.formset and cl.formset.is_multipart %} enctype=“multipart/form-data”{% endif %} novalidate>{% csrf_token %}
63 {% if cl.formset %}
64 {{ cl.formset.management_form }}
65 {% endif %}
66
67 {% block result_list %}
68 {% if action_form and actions_on_top and cl.show_admin_actions %}{% admin_actions %}{% endif %}
69 {% result_list cl %}
70 {% if action_form and actions_on_bottom and cl.show_admin_actions %}{% admin_actions %}{% endif %}
71 {% endblock %}
72 {% block pagination %}{% pagination cl %}{% endblock %}
73
74
75 {% block filters %}
76 {% if cl.has_filters %}
77
78 {% translate ‘Filter’ %}
79 {% if cl.is_facets_optional or cl.has_active_filters %}
Traceback Switch to copy-and-paste view
D:\Programming@Lumb\fap-new\fap-django.venv\Lib\site-packages\django\core\handlers\exception.py, line 55, in inner
response = get_response(request)
^^^^^^^^^^^^^^^^^^^^^ …
Local vars
D:\Programming@Lumb\fap-new\fap-django.venv\Lib\site-packages\django\core\handlers\base.py, line 220, in _get_response
response = response.render()
^^^^^^^^^^^^^^^^^ …
Local vars
D:\Programming@Lumb\fap-new\fap-django.venv\Lib\site-packages\django\template\response.py, line 114, in render
self.content = self.rendered_content
^^^^^^^^^^^^^^^^^^^^^ …
Local vars
D:\Programming@Lumb\fap-new\fap-django.venv\Lib\site-packages\django\template\response.py, line 92, in rendered_content
return template.render(context, self._request)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ …
Local vars
D:\Programming@Lumb\fap-new\fap-django.venv\Lib\site-packages\django\template\backends\django.py, line 107, in render
return self.template.render(context)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ …
Local vars
D:\Programming@Lumb\fap-new\fap-django.venv\Lib\site-packages\django\template\base.py, line 171, in render
return self._render(context)
^^^^^^^^^^^^^^^^^^^^^ …
Local vars
D:\Programming@Lumb\fap-new\fap-django.venv\Lib\site-packages\django\test\utils.py, line 114, in instrumented_test_render
return self.nodelist.render(context)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ …
Local vars
D:\Programming@Lumb\fap-new\fap-django.venv\Lib\site-packages\django\template\base.py, line 1016, in render
return SafeString(“”.join([node.render_annotated(context) for node in self]))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ …
Local vars
D:\Programming@Lumb\fap-new\fap-django.venv\Lib\site-packages\django\template\base.py, line 1016, in
return SafeString(“”.join([node.render_annotated(context) for node in self]))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ …
Local vars
D:\Programming@Lumb\fap-new\fap-django.venv\Lib\site-packages\django\template\base.py, line 977, in render_annotated
return self.render(context)
^^^^^^^^^^^^^^^^^^^^ …
Local vars
D:\Programming@Lumb\fap-new\fap-django.venv\Lib\site-packages\django\template\loader_tags.py, line 159, in render
return compiled_parent._render(context)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ …
Local vars
D:\Programming@Lumb\fap-new\fap-django.venv\Lib\site-packages\django\test\utils.py, line 114, in instrumented_test_render
return self.nodelist.render(context)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ …
Local vars
D:\Programming@Lumb\fap-new\fap-django.venv\Lib\site-packages\django\template\base.py, line 1016, in render
return SafeString(“”.join([node.render_annotated(context) for node in self]))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ …
Local vars
D:\Programming@Lumb\fap-new\fap-django.venv\Lib\site-packages\django\template\base.py, line 1016, in
return SafeString(“”.join([node.render_annotated(context) for node in self]))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ …
Local vars
D:\Programming@Lumb\fap-new\fap-django.venv\Lib\site-packages\django\template\base.py, line 977, in render_annotated
return self.render(context)
^^^^^^^^^^^^^^^^^^^^ …
Local vars
D:\Programming@Lumb\fap-new\fap-django.venv\Lib\site-packages\django\template\loader_tags.py, line 159, in render
return compiled_parent._render(context)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ …
Local vars
D:\Programming@Lumb\fap-new\fap-django.venv\Lib\site-packages\django\test\utils.py, line 114, in instrumented_test_render
return self.nodelist.render(context)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ …
Local vars
D:\Programming@Lumb\fap-new\fap-django.venv\Lib\site-packages\django\template\base.py, line 1016, in render
return SafeString(“”.join([node.render_annotated(context) for node in self]))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ …
Local vars
D:\Programming@Lumb\fap-new\fap-django.venv\Lib\site-packages\django\template\base.py, line 1016, in
return SafeString(“”.join([node.render_annotated(context) for node in self]))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ …
Local vars
D:\Programming@Lumb\fap-new\fap-django.venv\Lib\site-packages\django\template\base.py, line 977, in render_annotated
return self.render(context)
^^^^^^^^^^^^^^^^^^^^ …
Local vars
D:\Programming@Lumb\fap-new\fap-django.venv\Lib\site-packages\django\template\loader_tags.py, line 65, in render
result = block.nodelist.render(context)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ …
Local vars
D:\Programming@Lumb\fap-new\fap-django.venv\Lib\site-packages\django\template\base.py, line 1016, in render
return SafeString(“”.join([node.render_annotated(context) for node in self]))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ …
Local vars
D:\Programming@Lumb\fap-new\fap-django.venv\Lib\site-packages\django\template\base.py, line 1016, in
return SafeString(“”.join([node.render_annotated(context) for node in self]))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ …
Local vars
D:\Programming@Lumb\fap-new\fap-django.venv\Lib\site-packages\django\template\base.py, line 977, in render_annotated
return self.render(context)
^^^^^^^^^^^^^^^^^^^^ …
Local vars
D:\Programming@Lumb\fap-new\fap-django.venv\Lib\site-packages\django\template\loader_tags.py, line 65, in render
result = block.nodelist.render(context)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ …
Local vars
D:\Programming@Lumb\fap-new\fap-django.venv\Lib\site-packages\django\template\base.py, line 1016, in render
return SafeString(“”.join([node.render_annotated(context) for node in self]))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ …
Local vars
D:\Programming@Lumb\fap-new\fap-django.venv\Lib\site-packages\django\template\base.py, line 1016, in
return SafeString(“”.join([node.render_annotated(context) for node in self]))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ …
Local vars
D:\Programming@Lumb\fap-new\fap-django.venv\Lib\site-packages\django\template\base.py, line 977, in render_annotated
return self.render(context)
^^^^^^^^^^^^^^^^^^^^ …
Local vars
D:\Programming@Lumb\fap-new\fap-django.venv\Lib\site-packages\django\contrib\admin\templatetags\base.py, line 45, in render
return super().render(context)
^^^^^^^^^^^^^^^^^^^^^^^ …
Local vars
D:\Programming@Lumb\fap-new\fap-django.venv\Lib\site-packages\django\template\library.py, line 359, in render
_dict = self.func(*resolved_args, **resolved_kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ …
Local vars
D:\Programming@Lumb\fap-new\fap-django.venv\Lib\site-packages\django\contrib\admin\templatetags\admin_list.py, line 354, in result_list
“results”: list(results(cl)),
^^^^^^^^^^^^^^^^^ …
Local vars
D:\Programming@Lumb\fap-new\fap-django.venv\Lib\site-packages\django\contrib\admin\templatetags\admin_list.py, line 330, in results
yield ResultList(None, items_for_result(cl, res, None))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ …
Local vars
D:\Programming@Lumb\fap-new\fap-django.venv\Lib\site-packages\django\contrib\admin\templatetags\admin_list.py, line 321, in init
super().init(*items)
^^^^^^^^^^^^^^^^^^^^^^^^ …
Local vars
D:\Programming@Lumb\fap-new\fap-django.venv\Lib\site-packages\django\contrib\admin\templatetags\admin_list.py, line 246, in items_for_result
result_repr = display_for_field(

Local vars
Request information
USER

admin@Lumb.com

GET
No GET data

POST
No POST data

FILES
No FILES data

COOKIES
Variable Value
csrftoken

sessionid
'

META
Variable Value
ALLUSERSPROFILE
‘C:\ProgramData’
APPDATA
‘C:\Users\colateral\AppData\Roaming’
APP_TYPE
‘h2o’
ASYNCIO_DEBUGGER_ENV
‘True’
CHOCOLATEYINSTALL
‘C:\ProgramData\chocolatey’
CHOCOLATEYLASTPATHUPDATE
‘133990297150010926’
COMMONPROGRAMFILES
‘C:\Program Files\Common Files’
COMMONPROGRAMFILES(X86)
‘C:\Program Files (x86)\Common Files’
COMMONPROGRAMW6432
‘C:\Program Files\Common Files’
COMPUTERNAME
‘Lumb’
COMSPEC
‘C:\Windows\system32\cmd.exe’
CONTENT_LENGTH
‘’
CONTENT_TYPE
‘text/plain’
CSRF_COOKIE
‘cSKUdXYmvFRUaYNfbBYMRVpk47RfXR5g’
CSRF_COOKIE_NEEDS_UPDATE
True
CURL_CA_BUNDLE
‘C:\Program Files\PostgreSQL\17\ssl\certs\ca-bundle.crt’
DEBUG_LVL
‘5’
DJANGO_SETTINGS_MODULE
‘settings.develop’
DRIVERDATA
‘C:\Windows\System32\Drivers\DriverData’
EFC_30744_1262719628
‘1’
EFC_30744_1592913036
‘1’
EFC_30744_2283032206
‘1’
EFC_30744_2775293581
‘1’
EFC_30744_3789132940
‘1’
GATEWAY_INTERFACE
‘CGI/1.1’
GDAL_DATA
‘C:\Program Files\PostgreSQL\17\gdal-data’
GDAL_LIB
‘D:\ProgramFiles\python\3_11_1\Lib\site-packages\osgeo;GDAL_DATA=d:\ProgramFiles\python\python310_9\Lib\site-packages\osgeo\data\gdal;GDAL_LIB=d:\ProgramFiles\python\python310_9\Lib\site-packages\osgeo;GDAL_LIBRARY_PATH=d:\ProgramFiles\python\python310_9\Lib\site-packages\osgeo\gdal304.dll’
GDAL_LIBRARY_PATH
‘D:\ProgramFiles\python\3_11_1\Lib\site-packages\osgeo\gdal304.dll’
GEOS_LIBRARY_PATH
‘D:\ProgramFiles\python\3_11_1\Lib\site-packages\osgeo\geos_c.dll’
HALT_VARIABLE_RESOLVE_THREADS_ON_STEP_RESUME
‘True’
HOMEDRIVE
‘C:’
HOMEPATH
‘\Users\colateral’
HTTP_ACCEPT
‘text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,/;q=0.8,application/signed-exchange;v=b3;q=0.7’
HTTP_ACCEPT_ENCODING
‘gzip, deflate, br, zstd’
HTTP_ACCEPT_LANGUAGE
‘en-US,en;q=0.9,fr;q=0.8,en-GB;q=0.7,fr-FR;q=0.6,ro-RO;q=0.5,ro;q=0.4,pl;q=0.3’
HTTP_CONNECTION
‘keep-alive’

‘‘‘

Hello Ken,

I have to apology. Because I am new user I have limitations in number of characters and links on the post. I replaced all links with http_ also truncate the error output. See above what you requested

Regarding the error …. this is only on Django 5.2.25… for instance 5.1.11 is working fine

No worries. (But part of the problem is caused by you using the > at the beginning of each posted line instead of surrounding the entire block of text between lines of ``` as I mentioned in my “Side note” above. )

This is a general symptom that you have something in your code, or a third-party module, that is no longer valid in Django 5.2.

I’d start with checking the third-party libraries. A pip list -o will show you which libraries need to be updated. I’d suggest updating them first.

I also see where you are installing django-jsonfield - it’s obsolete and should be removed. (It’s also not needed anymore now that Django provides a built-in JSONfield.)

You have other packages listed that are obsolete and potentially problematic with Django 5.2 such as djangorestframework-filters==1.0.0.dev0 and drf-yasg. (There may be more, these are just a couple that I spot-checked.)

Any Django-specific package without a release in 2025 should be looked at more closely. You can check the github issues for the libraries to see if there’s any reported issues for Django 5.2.

Thank you. I have all packaged updated to last version. The issue was with django-json that was used by stripe…. I remove it Now all OK. For 5.2 there is a way to know what django libraries are deprecated and what versions are recommended ?

Thank you.

I’m not aware of any direct tooling to identify when a package is no longer valid with Django - other than running with the -Wd option to show the deprecation warnings. (e.g. python -Wd manage.py check or python -Wd manage.py runserver, etc)

For third-party libraries, my rule-of-thumb is to stay current. Anytime I touch a project, I look to update the libraries it’s using.