Type Error from Django code on Upgrade to 4.2.7

I have followed the advice in this presentation for upgrading Django to the latest version.

Euro Python Conference - Django Upgrade Presentation

And all has gone well until the final step. After upgrading to 4.2.7 (a library I needed didn’t have a version for 4.2.8) and Python 3.11.6 – I hit the following error when running Test All Tests in PyCharm.

Traceback (most recent call last):
  File "/Applications/PyCharm.app/Contents/plugins/python/helpers/pycharm/django_test_manage.py", line 56, in <module>
  File "/Users/john.bickerstaff/Documents/workspace/employee-maestro/venv_Django_4.2.7/lib/python3.11/site-packages/django/__init__.py", line 24, in setup
  File "/Users/john.bickerstaff/Documents/workspace/employee-maestro/venv_Django_4.2.7/lib/python3.11/site-packages/django/apps/registry.py", line 124, in populate
  File "/Users/john.bickerstaff/Documents/workspace/employee-maestro/venv_Django_4.2.7/lib/python3.11/site-packages/django/contrib/admin/apps.py", line 27, in ready
  File "/Users/john.bickerstaff/Documents/workspace/employee-maestro/venv_Django_4.2.7/lib/python3.11/site-packages/django/contrib/admin/__init__.py", line 50, in autodiscover
    autodiscover_modules("admin", register_to=site)
  File "/Users/john.bickerstaff/Documents/workspace/employee-maestro/venv_Django_4.2.7/lib/python3.11/site-packages/django/utils/module_loading.py", line 58, in autodiscover_modules
    import_module("%s.%s" % (app_config.name, module_to_search))
  File "/usr/local/Cellar/python@3.11/3.11.6_1/Frameworks/Python.framework/Versions/3.11/lib/python3.11/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1204, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1176, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1147, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 690, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 940, in exec_module
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "/Users/john.bickerstaff/Documents/workspace/employee-maestro/venv_Django_4.2.7/lib/python3.11/site-packages/import_export/admin.py", line 521, in <module>
    class ExportActionMixin(ExportMixin):
  File "/Users/john.bickerstaff/Documents/workspace/employee-maestro/venv_Django_4.2.7/lib/python3.11/site-packages/import_export/admin.py", line 566, in ExportActionMixin
    actions = admin.ModelAdmin.actions + [export_admin_action]
TypeError: can only concatenate tuple (not "list") to tuple

This is deep in Django code - the ExportActionMixin class. I’m not sure what is going on here. I’m sure all this code was tested against 3.11 before releasing 4.2.7…

Any thoughts, hints or ideas greatly appreciated…

Are you using the django-import-export package? If so, what version of it are you using?

Yes. It looks like this. I can’t see how to derive a version.


I did use a brand new venv, set the Django version to 4.2.7 and run pip install requirements.txt in order to have a clean workspace.

Also, a previous venv for 4.0.10 has the exact same line of code and all tests ran against 3.11

The version is either going to be in the requirements.txt file, or you can issue a pip list to see which version is installed.

Thank you!

django-import-export==2.5.0 from requirements.txt

I did the “thing” of letting pip choose the versions for the django dependencies…

That’s pretty old, isn’t it… Hmmmm…

Maybe I try upgrading and re-run? I’ll try…

Well… That solved it.

I have new errors, but suspect that the pip “magic dependency thing” didn’t work as well as I’d hoped and that I’m going to have to turn over the rocks one at a time…

Per the video: “pip > 20.3 will resolve dependencies for Django-related libraries if you leave the version numbers off…”

Thanks guys!!!