﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
35153	FORMAT_MODULE_PATH not acting as I expected.	Paul Hermans	Emmanuel Sandjio	"I am not certain this is a bug, but may be more of a confusion of a new user (me). Here is what I found:

In my **settings**:

{{{
LANGUAGE_CODE='en-us'
TIME_ZONE = 'America/New_York'
FORMAT_MODULE_PATH = [
    ""student_track.formats"",
]
USE_L10N=True
USE_I18N = True
USE_TZ = True
USE_THOUSAND_SEPARATOR = True
}}}

then in my student_track app:
I had this file:
{{{
/formats/en_us/formats.py
}}}
but this failed to load (no error message). Eventually I figured out to change the file path to this (Note the Upper Case for the country):
{{{
/formats/en_US/formats.py
}}}

In my **formats.py** i still have:
{{{
DATE_FORMAT = ""M. d, Y""
TIME_FORMAT = ""h:i a""

DATETIME_FORMAT = ""M. d Y h:i a""
# DATETIME_FORMAT = f""{DATE_FORMAT} {TIME_FORMAT}""


DATE_INPUT_FORMATS = [
    '%m/%d/%Y', '%m/%d/%y', '%Y-%m-%d',  # '2006-10-25', '10/25/2006', '10/25/06'
    '%b %d %Y', '%b %d, %Y',  # 'Oct 25 2006', 'Oct 25, 2006'
    '%d %b %Y', '%d %b, %Y',  # '25 Oct 2006', '25 Oct, 2006'
    '%B %d %Y', '%B %d, %Y',  # 'October 25 2006', 'October 25, 2006'
    '%d %B %Y', '%d %B, %Y',  # '25 October 2006', '25 October, 2006'
]
}}}

**Template** I now have:
{{{
<td class=""text-start"" >{{ record.actual_date }} </td>
}}}
and all is working well.

Where I think the issue is that the folder name did not match the language I specified in the settings file and I didn't understand that from the documentation.
When I stepped through the code, it seems that this change occurs in the  **django.utils.formats.py** file when iter_format_modules() is called:

{{{
def iter_format_modules(lang, format_module_path=None):
    """"""Find format modules.""""""
    if not check_for_language(lang):
        return

    if format_module_path is None:
        format_module_path = settings.FORMAT_MODULE_PATH

    format_locations = []
    if format_module_path:
        if isinstance(format_module_path, str):
            format_module_path = [format_module_path]
        for path in format_module_path:
            format_locations.append(path + "".%s"")
    format_locations.append(""django.conf.locale.%s"")
    locale = to_locale(lang)
    locales = [locale]
    if ""_"" in locale:
        locales.append(locale.split(""_"")[0])
    for location in format_locations:
        for loc in locales:
            try:
                yield import_module(""%s.formats"" % (location % loc))
            except ImportError:
                pass
}}}

In my case, this failed with an ImportError, and when I looked into its details, it seems that this line:
{{{
    locale = to_locale(lang)
}}}

converted had my language specified in settings (en-us) to ""en_US"". 

I don't exactly know why, but it seems intentional. Assuming this is behaving as expected, then it seems that the documentation should be updated to indicate how this works. 

I am so new to Django that I am hesitant to propose the actual text that should change, but would be happy to try/help if this seems like the reasonable solution. "	Cleanup/optimization	closed	Documentation	5.0	Normal	fixed	FORMAT_MODULE_PATH	Paul Hermans	Ready for checkin	1	0	0	0	1	0
