Opened 6 years ago

Closed 6 years ago

Last modified 5 years ago

#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 Jon Dufresne, 6 years ago

Has patch: set

PR

Additionally, there was some discussion of this in PR#10428 which motivated this work.

comment:2 by Carlton Gibson, 6 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 Carlton Gibson, 6 years ago

Resolution: wontfix
Status: newclosed

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 Carlton Gibson, 6 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.)

Last edited 6 years ago by Carlton Gibson (previous) (diff)

comment:5 by Carlton Gibson, 6 years ago

Resolution: wontfix
Status: closednew

comment:6 by Tim Graham, 6 years ago

Triage Stage: UnreviewedAccepted

comment:7 by Tim Graham <timograham@…>, 6 years ago

Resolution: fixed
Status: newclosed

In 0cd465b:

Fixed #29817 -- Deprecated settings.FILE_CHARSET.

comment:8 by Mariusz Felisiak <felisiak.mariusz@…>, 5 years ago

In 3d716467:

Refs #29817 -- Removed settings.FILE_CHARSET per deprecation timeline.

Note: See TracTickets for help on using tickets.
Back to Top