#29817 closed Cleanup/optimization (fixed)
Deprecate FILE_CHARSET setting
| Reported by: | Jon Dufresne | Owned by: | nobody |
|---|---|---|---|
| Component: | Core (Other) | Version: | dev |
| Severity: | Normal | Keywords: | |
| Cc: | Triage Stage: | Accepted | |
| Has patch: | yes | Needs documentation: | no |
| Needs tests: | no | Patch needs improvement: | no |
| Easy pickings: | no | UI/UX: | no |
Description
The setting was introduced in 953badbea5a04159adbfa970f5805c0232b6a401.
It looks as settings.FILE_CHARSET is no longer necessary and could easily be deprecated. Its existence is justified as:
But the common case is to read templates from the filesystem, and this creates a slight complication: not all filesystems store their data encoded as UTF-8. If your template files are not stored with a UTF-8 encoding, set the FILE_CHARSET setting to the encoding of the files on disk. When Django reads in a template file, it will convert the data from this encoding to Unicode.
Which seems suspect to me. I'm not aware of any modern environment that can't UTF-8 encode files to disk.
Its use is extremely limited in the code. After removal, we could instead document that files must be encoded using UTF-8.
Much like DEFAULT_CONTENT_TYPE, this setting doesn't play well with third-party libraries. If a project were to use this setting, it might be unable to load templates from third-party libraries that used the default UTF-8 encoding.
Further, this setting is entirely untested.
Change History (8)
comment:1 by , 7 years ago
| Has patch: | set |
|---|
comment:2 by , 7 years ago
This would be nice. Django-developers thread asking for input: https://groups.google.com/d/topic/django-developers/7bZbYVV6hg4/discussion — lets see if there are any issues raised.
comment:3 by , 7 years ago
| Resolution: | → wontfix |
|---|---|
| Status: | new → closed |
Initial feedback on the thread is that this probably IS needed. I'm going to close as wontfix on that basis, but happy to reopen if the discussion develops there.
comment:4 by , 7 years ago
So the discussion evolves such that it looks like the only issue here would be enforcing the use of UTF-8 in editors (for template files etc).
Is that something we want to do? (Not, as yet, answers on the thread re that.)
comment:5 by , 7 years ago
| Resolution: | wontfix |
|---|---|
| Status: | closed → new |
comment:6 by , 7 years ago
| Triage Stage: | Unreviewed → Accepted |
|---|
PR
Additionally, there was some discussion of this in PR#10428 which motivated this work.