Opened 14 months ago

Closed 13 months ago

Last modified 2 months ago

#29817 closed Cleanup/optimization (fixed)

Deprecate FILE_CHARSET setting

Reported by: Jon Dufresne Owned by: nobody
Component: Core (Other) Version: master
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 Changed 14 months ago by Jon Dufresne

Has patch: set

PR

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

comment:2 Changed 14 months ago by Carlton Gibson

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 Changed 14 months ago by Carlton Gibson

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 Changed 14 months ago by Carlton Gibson

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 14 months ago by Carlton Gibson (previous) (diff)

comment:5 Changed 14 months ago by Carlton Gibson

Resolution: wontfix
Status: closednew

comment:6 Changed 13 months ago by Tim Graham

Triage Stage: UnreviewedAccepted

comment:7 Changed 13 months ago by Tim Graham <timograham@…>

Resolution: fixed
Status: newclosed

In 0cd465b:

Fixed #29817 -- Deprecated settings.FILE_CHARSET.

comment:8 Changed 2 months ago by Mariusz Felisiak <felisiak.mariusz@…>

In 3d716467:

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

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