Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Delete USE_L10N setting if Django version >= 4.0 #161

Closed
johnnymetz opened this issue Jul 4, 2022 · 4 comments · Fixed by #173
Closed

Delete USE_L10N setting if Django version >= 4.0 #161

johnnymetz opened this issue Jul 4, 2022 · 4 comments · Fixed by #173

Comments

@johnnymetz
Copy link
Contributor

Description

The USE_L10N setting is deprecated in Django 4.0: https://docs.djangoproject.com/en/4.0/ref/settings/#std-setting-USE_L10N

Figure this would be a good candidate for this project. Happy to work on it if you agree.

@johnnymetz johnnymetz changed the title Delete USE_L10N setting if Django version >= 4.0 Delete USE_L10N setting if Django version >= 4.0 Jul 4, 2022
@adamchainz
Copy link
Owner

Yeah we could remove it, but only if it's set to exactly True: USE_L10N = True.

The password_reset_timeout_days fixer rewrites another setting, you can use that for guidance.

Please ensure you test, update docs, and add a changelog note.

@johnnymetz
Copy link
Contributor Author

There are two changes here. According to the settings page: https://docs.djangoproject.com/en/4.0/ref/settings/#std-setting-USE_L10N

  • Changed in Django 4.0: In older versions, the default value is False.
  • Deprecated since version 4.0: This setting is deprecated. Starting with Django 5.0, localized formatting of data will always be enabled. For example Django will display numbers and dates using the format of the current locale.

How should we handle this? I imagine:

  • Django 4.x:
    • If USE_L10N = True: remove the setting
    • If USE_L10N = False: no action
  • Django 5.x:
    • If USE_L10N = True: remove the setting
    • If USE_L10N = False: not totally sure what to do here. Probably remove it because it has no effect. But I'm slightly worried this may confuse the user. They may think their app's behavior is changing because django-upgrade removed the setting when it's in fact due to a library change. But I'm sure the Fixers docs will clarify this so maybe I shouldn't be so concerned.

Or should we just not worry about Django 5.0 yet because it hasn't been released yet?

@adamchainz
Copy link
Owner

I don't see it as the responsibility of django-upgrade to worry about USE_L10N = False. django-upgrade updates files where it's definitely safe to do so.

Django will log a deprecation warning for it from version 4.0. If users ignore that all the way through to version 5.0, that's on them. At that point, leaving the single line in their settings file is going to be the least of their problems, and may even help them debug localization problems.

@johnnymetz
Copy link
Contributor Author

Sounds great! Just put up the initial PR. I left USE_L10N = False alone.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants