Upgrade repo deps to Django >= 5.1 and fix incompatibilities#153
Upgrade repo deps to Django >= 5.1 and fix incompatibilities#153Copilot wants to merge 1 commit intomaster_pbsfrom
Conversation
- Update setup.py: require django>=5.1, remove six dependency, relax pinned versions for django_polymorphic and django-js-asset - Remove six import in filer/utils/model_label.py, use str directly - Replace force_text with force_str in admin_utils.py - Replace ugettext_lazy with gettext_lazy in folderadmin.py - Remove allow_tags attribute (no longer used by modern Django) - Replace urlquote with urllib.parse.quote in foldermodels.py - Remove use_for_related_fields from managers (removed in Django 3.0+) - Rename __unicode__ to __str__ in models - Replace url() with path() in test_urls.py, fix admin.site.urls usage - Replace NoArgsCommand/option_list with BaseCommand/add_arguments - Remove default_app_config from __init__.py - Rename MIDDLEWARE_CLASSES to MIDDLEWARE in test_settings.py - Update tox.ini for modern Python/Django - Remove filer/south_migrations/ directory (South long unsupported) Agent-Logs-Url: https://github.com/pbs/django-filer/sessions/acd29442-f148-4eca-8866-86798003b1e2 Co-authored-by: andreilupuleasa <124138251+andreilupuleasa@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
This PR upgrades the project’s minimum supported Django version to 5.1 and updates/removes deprecated/removed APIs and legacy patterns throughout django-filer to restore compatibility.
Changes:
- Bumps core dependency floor to
django>=5.1and modernizestox.initest environment. - Replaces removed Django APIs (e.g.,
force_text,ugettext_lazy,urlquote,url()) with supported equivalents. - Removes legacy/dead code patterns (e.g.,
use_for_related_fields,allow_tags,default_app_config, South migrations,__unicode__shims).
Reviewed changes
Copilot reviewed 36 out of 37 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
tox.ini |
Updates tox env/deps for Django 5.1 and Python 3.12. |
setup.py |
Raises Django minimum version; removes six; relaxes strict pins. |
filer/utils/model_label.py |
Removes six usage; uses str for label detection. |
filer/test_urls.py |
Migrates URLconf from url() to path() patterns. |
filer/test_settings.py |
Updates middleware setting to modern MIDDLEWARE. |
filer/south_migrations/* |
Removes legacy South migrations directory content. |
filer/models/imagemodels.py |
Drops redundant __str__ delegating to removed __unicode__. |
filer/models/foldermodels.py |
Removes no-op manager flag; switches urlquote to urllib.parse.quote; replaces __unicode__ with __str__. |
filer/models/filemodels.py |
Removes no-op manager flag; replaces __unicode__ with __str__ and removes redundant wrapper. |
filer/models/clipboardmodels.py |
Replaces __unicode__ with __str__. |
filer/management/commands/import_files.py |
Migrates command API to BaseCommand.add_arguments()/handle(). |
filer/admin/patched/admin_utils.py |
Replaces force_text() with force_str(). |
filer/admin/folderadmin.py |
Removes allow_tags; replaces ugettext_lazy() with gettext_lazy(). |
filer/__init__.py |
Removes deprecated default_app_config. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| deps= | ||
| pytest == 3.4.0 | ||
| pytest-django == 3.1.2 | ||
| Django>=1.8,<1.9a | ||
| django-cms-roles>0.7.0.pbs,<0.7.0.pbs.1000 | ||
| django-cms>=2.3.5pbs,<2.3.5pbs.1000 | ||
| django-mptt==0.7.4 | ||
| changedir= | ||
| {envdir} | ||
| pytest | ||
| pytest-django | ||
| Django>=5.1 | ||
| django-mptt>=0.6,<1.0 | ||
| django_polymorphic>=4.0.0 | ||
| django-js-asset>=2.0.0 | ||
| easy-thumbnails>=2,<3.0 | ||
| Unidecode>=0.04,<1.2 |
There was a problem hiding this comment.
tox.ini installs only Django/mptt/polymorphic/etc, but the test settings used by tox (--ds=filer.test_settings) include cms, menus, sekizai, and cmsroles in INSTALLED_APPS. With the current deps list, running tox will fail during Django setup with ImportError/ModuleNotFoundError. Add the missing test-only dependencies to this env (or remove those apps from filer.test_settings/tests if they’re no longer required).
| def handle(self, **options): | ||
| file_importer = FileImporter(**options) | ||
| file_importer.walker() |
There was a problem hiding this comment.
Now that the command subclasses BaseCommand, handle() may be invoked with positional args (self.handle(*args, **options)). Defining handle(self, **options) will raise TypeError if any args are provided (previously NoArgsCommand rejected args cleanly). Consider accepting *args and either ignoring them or raising a CommandError with a helpful message when unexpected args are provided.
Django 5.1 removed several APIs that were deprecated across Django 3.x–5.0. This PR updates the minimum Django requirement to 5.1 and fixes all broken call sites.
Removed API replacements
six.string_types→str(filer/utils/model_label.py)force_text()→force_str()(admin/patched/admin_utils.py)ugettext_lazy()→gettext_lazy()(admin/folderadmin.py)urlquote()→urllib.parse.quote()(models/foldermodels.py)url()→path(),include(admin.site.urls)→admin.site.urls(test_urls.py)NoArgsCommand/option_list/make_option→BaseCommand/add_arguments()(management/commands/import_files.py)Dead code & deprecated patterns removed
allow_tags = Trueon admin method (Django handlesmark_safedirectly)use_for_related_fields = Trueon managers (no-op since Django 2.0)default_app_configin__init__.py(auto-detected since Django 3.2)MIDDLEWARE_CLASSES→MIDDLEWAREin test settings__unicode__→__str__across model classesfiler/south_migrations/entirely (24 files; South has been dead for years)Dependency updates (
setup.py,tox.ini)django>=4.2→django>=5.1sixfrominstall_requiresdjango_polymorphicanddjango-js-assetfrom exact pins to>=floorsargparsefromtests_requiretox.ini(was targeting Python 2.7 / Django 1.8)