fix URLPathVersioning reverse fallback by jornvanwier · Pull Request #7247 · encode/django-rest-framework (original) (raw)

When using URLPathVersioning reverse adds request.version to the kwargs and tries to find a match. If that fails, it falls back to the default reverse function (which doesn't add the version to the kwargs.

However, without this fix the kwargs parameter is modified, which leads to the fallback reverse function having the same behaviour as the URLPathVersioning variant, which makes it impossible to reverse a view that doesn't have versioning.

With this change a copy of kwargs is created instead.

I ran tox didn't see any new issues caused by my changes.