Skip to content

Upgrade repo deps to Django >= 5.1 and fix incompatibilities#153

Draft
Copilot wants to merge 1 commit intomaster_pbsfrom
copilot/upgrade-repo-deps-django-5-1
Draft

Upgrade repo deps to Django >= 5.1 and fix incompatibilities#153
Copilot wants to merge 1 commit intomaster_pbsfrom
copilot/upgrade-repo-deps-django-5-1

Conversation

Copy link
Copy Markdown

Copilot AI commented Apr 24, 2026

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_typesstr (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_optionBaseCommand / add_arguments() (management/commands/import_files.py)

Dead code & deprecated patterns removed

  • allow_tags = True on admin method (Django handles mark_safe directly)
  • use_for_related_fields = True on managers (no-op since Django 2.0)
  • default_app_config in __init__.py (auto-detected since Django 3.2)
  • MIDDLEWARE_CLASSESMIDDLEWARE in test settings
  • __unicode____str__ across model classes
  • Deleted filer/south_migrations/ entirely (24 files; South has been dead for years)

Dependency updates (setup.py, tox.ini)

  • django>=4.2django>=5.1
  • Removed six from install_requires
  • Relaxed django_polymorphic and django-js-asset from exact pins to >= floors
  • Removed Python 2.6 argparse from tests_require
  • Modernized tox.ini (was targeting Python 2.7 / Django 1.8)

- 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>
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.1 and modernizes tox.ini test 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.

Comment thread tox.ini
Comment on lines 5 to +13
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
Copy link

Copilot AI Apr 24, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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).

Copilot uses AI. Check for mistakes.
Comment on lines +129 to 131
def handle(self, **options):
file_importer = FileImporter(**options)
file_importer.walker()
Copy link

Copilot AI Apr 24, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants