Skip to content

Modernize support for Django 5.2 and 6.0#14

Merged
pyanderson merged 2 commits into
developfrom
django-52-60-modernization
May 21, 2026
Merged

Modernize support for Django 5.2 and 6.0#14
pyanderson merged 2 commits into
developfrom
django-52-60-modernization

Conversation

@pyanderson

Copy link
Copy Markdown

Summary

This PR modernizes django-js-reverse for currently supported Django releases.

What changed

  • add official support for Django 5.2 LTS and 6.0
  • update the tox matrix to match the supported Python/Django combinations
  • migrate CI from Travis CI to GitHub Actions
  • update package metadata and public links to point to the Vinta-maintained fork
  • modernize Django imports and test URL configuration to remove legacy compatibility code
  • adjust namespace resolver handling for modern Django versions
  • document the js2py limitation on Python 3.13+
  • refresh README and changelog entries

How to test

  1. Create and activate a Python 3.13 virtual environment.
  2. Install tox: python -m pip install tox.
  3. Run the Django 5.2 test suite: python -m tox -e py313-django52.
  4. Run the Django 6.0 test suite: python -m tox -e py313-django60.
  5. Run metadata/documentation checks: python -m tox -e lint.
  6. Regenerate the JS package artifacts: python -m tox -e prepare_npm.
  7. Build the source and wheel distributions: python -m tox -e release.

Notes

  • js2py is skipped on Python 3.13+ because it depends on Python bytecode details that changed in Python 3.13.

@pyanderson pyanderson self-assigned this May 21, 2026
Comment thread README.rst
Comment on lines +59 to +67
| 3.14 | 6.0, 5.2 |
+----------------+--------------------+
| 3.13 | 6.0, 5.2 |
+----------------+--------------------+
| 3.10 | 4.2, 4.1, 4.0, 3.2 |
| 3.12 | 6.0, 5.2 |
+----------------+--------------------+
| 3.9 | 4.2, 4.1, 4.0, 3.2 |
| 3.11 | 5.2 |
+----------------+--------------------+
| 3.8 | 4.2, 4.1, 4.0, 3.2 |
| 3.10 | 5.2 |

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Using the Django documentation as reference: What Python version can I use with Django?

On this PR creation these are the references:

Image Image

Comment on lines +49 to +50
- name: Set up Node.js
uses: actions/setup-node@v4

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

We have a test that checks the output of the node command. Although some systems already come with a version of Node installed, I decided to be more conservative and ensure that we have Node installed.

Comment on lines -13 to -19
try:
from django.urls import get_resolver
except ImportError:
from django.core.urlresolvers import get_resolver

REQUIRES_SYSTEM_CHECKS = [False]

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Since we will no longer support very old versions, this and other similar fallbacks have been removed.

Comment on lines +24 to +30
js2py = None
# Js2Py relies on Python bytecode details that changed in Python 3.13.
if sys.version_info < (3, 13):
try:
import js2py
except (ImportError, RuntimeError):
js2py = None

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

You can see more details about the issue here. There's a fork that apparently solves the problem, but I think it would add unnecessary overhead to the library at the moment.

Comment thread django_js_reverse/core.py
Comment on lines -32 to -35
if sys.version < '3':
text_type = unicode # NOQA
else:
text_type = str

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Fallbacks for older versions of Python have also been removed.

@pyanderson pyanderson requested review from Copilot and fjsj and removed request for Copilot May 21, 2026 15:34
Comment thread django_js_reverse/tests/settings.py Outdated
'context_processors': [
'django.template.context_processors.request',
],
},

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Is this now necessary for the lib to work? If so, is it documented?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

No, this is only needed by the test setup, not by the library. But I can move it to an override decorator.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Fine to keep here, maybe add a comment saying this is for tests only


self.assertEqual(node_jseval(module), url(node_jseval))
self.assertEqual(js2py_jseval('(function () {{ {} }}())'.format(script)), url(js2py_jseval))
if js2py is not None:

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

ideally the test should test with and without js2py (if it's optional)

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Agree. The current tox/GitHub Actions matrix already exercises both paths: with js2py on Python 3.10-3.12 and without it on 3.13+. Do you recommend any changes?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

If matrix treats that, it's fine

Comment thread django_js_reverse/core.py Outdated
inner_urlresolver = urlresolvers.get_ns_resolver(
inner_ns_path,
inner_urlresolver,
tuple(getattr(urlresolver.pattern, 'converters', {}).items()),

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

is this getattr necessary? is converters added by the lib or by a dep?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

No, it's not necessary. I only kept it as a defensive compatibility measure, but I looked at the Django API, and it's really not needed, so I'll remove it.

Comment thread README.rst Outdated

Django JS Reverse is a small django app that makes url handling of
`named urls <https://docs.djangoproject.com/en/dev/topics/http/urls/#naming-url-patterns>`__ in javascript easy and non-annoying..
`named urls <https://docs.djangoproject.com/en/6.0/topics/http/urls/#naming-url-patterns>`__ in javascript easy and non-annoying..

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Maybe keep linked to dev?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

I think stable it's better, gonna change it.

@fjsj fjsj left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Looks good overall, I left some questions

@pyanderson pyanderson requested a review from fjsj May 21, 2026 17:56

@fjsj fjsj left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM, I think the new release should be a major one to avoid breaking old Django installs.

@pyanderson pyanderson merged commit e7053d5 into develop May 21, 2026
5 checks passed
@pyanderson pyanderson deleted the django-52-60-modernization branch May 21, 2026 19:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants