#35153: FORMAT_MODULE_PATH not acting as I expected.
               Reporter:  Paul       |          Owner:  nobody
  Hermans                            |
                   Type:  Bug        |         Status:  new
              Component:             |        Version:  5.0
  Documentation                      |
               Severity:  Normal     |       Keywords:  FORMAT_MODULE_PATH
           Triage Stage:             |      Has patch:  0
  Unreviewed                         |
    Needs documentation:  0          |    Needs tests:  0
Patch needs improvement:  0          |  Easy pickings:  1
                  UI/UX:  0          |
 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**:

 TIME_ZONE = 'America/New_York'
 USE_I18N = True
 USE_TZ = True

 then in my student_track app:
 I had this file:
 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):

 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"

     '%m/%d/%Y', '%m/%d/%y', '%Y-%m-%d',  # '2006-10-25', '10/25/2006',
     '%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
 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):

     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")
     locale = to_locale(lang)
     locales = [locale]
     if "_" in locale:
     for location in format_locations:
         for loc in locales:
                 yield import_module("%s.formats" % (location % loc))
             except ImportError:

 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.
Ticket URL: <https://code.djangoproject.com/ticket/35153>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To view this discussion on the web visit 

Reply via email to