Opened 4 years ago
Last modified 4 years ago
#32180 closed Cleanup/optimization
FileBasedCache accepts relative directorires as a LOCATION documentation say should be absolute — at Initial Version
Reported by: | Carles Pina Estany | Owned by: | Carles Pina Estany |
---|---|---|---|
Component: | Core (System checks) | Version: | dev |
Severity: | Normal | Keywords: | |
Cc: | Triage Stage: | Ready for checkin | |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
FileBasedCache LOCATION: the documentation says that the path should be absolute, Django accepts absolute or relative.
In https://docs.djangoproject.com/en/3.1/topics/cache/#filesystem-caching
It says:
"The directory path should be absolute – that is, it should start at the root of your filesystem."
The code makes them absolute:
https://github.com/django/django/blob/master/django/core/cache/backends/filebased.py#L22
Enforcing the LOCATION to be specified only in absolute way might have no gain and would have backwards compatibility problems for deployments that are passing the directory using a relative path.
A possible way to improve the situation without or minimal backwards incompatibility changes would be to add a new check (thanks Carlton for the idea).