Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
D
django
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
django
Commits
5abc811a
Kaydet (Commit)
5abc811a
authored
May 19, 2014
tarafından
Tim Graham
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Revert "Fixed #20477: Allowed settings.FORMAT_MODULE_PATH to be a list of modules."
This reverts commit
950b6de1
.
üst
a1f0c4c6
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
9 additions
and
103 deletions
+9
-103
formats.py
django/utils/formats.py
+4
-9
settings.txt
docs/ref/settings.txt
+0
-14
1.8.txt
docs/releases/1.8.txt
+1
-4
formatting.txt
docs/topics/i18n/formatting.txt
+4
-13
test_formats.py
tests/utils_tests/test_formats.py
+0
-59
__init__.py
tests/utils_tests/test_module/formats/__init__.py
+0
-4
__init__.py
tests/utils_tests/test_module/formats/en/__init__.py
+0
-0
formats.py
tests/utils_tests/test_module/formats/en/formats.py
+0
-0
__init__.py
tests/utils_tests/test_module/formats2/__init__.py
+0
-0
__init__.py
tests/utils_tests/test_module/formats2/en/__init__.py
+0
-0
formats.py
tests/utils_tests/test_module/formats2/en/formats.py
+0
-0
No files found.
django/utils/formats.py
Dosyayı görüntüle @
5abc811a
...
@@ -47,15 +47,10 @@ def iter_format_modules(lang, format_module_path=None):
...
@@ -47,15 +47,10 @@ def iter_format_modules(lang, format_module_path=None):
Does the heavy lifting of finding format modules.
Does the heavy lifting of finding format modules.
"""
"""
if
check_for_language
(
lang
):
if
check_for_language
(
lang
):
format_locations
=
[]
format_locations
=
[
'django.conf.locale.
%
s'
]
if
settings
.
FORMAT_MODULE_PATH
:
if
format_module_path
:
if
isinstance
(
settings
.
FORMAT_MODULE_PATH
,
six
.
string_types
):
format_locations
.
append
(
format_module_path
+
'.
%
s'
)
format_module_path_setting
=
[
settings
.
FORMAT_MODULE_PATH
]
format_locations
.
reverse
()
else
:
format_module_path_setting
=
settings
.
FORMAT_MODULE_PATH
for
path
in
format_module_path_setting
:
format_locations
.
append
(
path
+
'.
%
s'
)
format_locations
.
append
(
'django.conf.locale.
%
s'
)
locale
=
to_locale
(
lang
)
locale
=
to_locale
(
lang
)
locales
=
[
locale
]
locales
=
[
locale
]
if
'_'
in
locale
:
if
'_'
in
locale
:
...
...
docs/ref/settings.txt
Dosyayı görüntüle @
5abc811a
...
@@ -1378,20 +1378,6 @@ like::
...
@@ -1378,20 +1378,6 @@ like::
__init__.py
__init__.py
formats.py
formats.py
.. versionchanged:: 1.8
You can also set this setting to a list of Python paths, for example::
FORMAT_MODULE_PATH = [
'mysite.formats',
'some_app.formats',
]
When Django searches for a certain format, it will go through all given
Python paths until it finds a module that actually defines the given
format. This means that formats defined in packages farther up in the list
will take precedence over the same formats in packages farther down.
Available formats are :setting:`DATE_FORMAT`, :setting:`TIME_FORMAT`,
Available formats are :setting:`DATE_FORMAT`, :setting:`TIME_FORMAT`,
:setting:`DATETIME_FORMAT`, :setting:`YEAR_MONTH_FORMAT`,
:setting:`DATETIME_FORMAT`, :setting:`YEAR_MONTH_FORMAT`,
:setting:`MONTH_DAY_FORMAT`, :setting:`SHORT_DATE_FORMAT`,
:setting:`MONTH_DAY_FORMAT`, :setting:`SHORT_DATE_FORMAT`,
...
...
docs/releases/1.8.txt
Dosyayı görüntüle @
5abc811a
...
@@ -133,10 +133,7 @@ Forms
...
@@ -133,10 +133,7 @@ Forms
Internationalization
Internationalization
^^^^^^^^^^^^^^^^^^^^
^^^^^^^^^^^^^^^^^^^^
* :setting:`FORMAT_MODULE_PATH` can now be a list of strings representing
* ...
module paths. This allows importing several format modules from different
reusable apps. It also allows overriding those custom formats in your main
Django project.
Management Commands
Management Commands
^^^^^^^^^^^^^^^^^^^
^^^^^^^^^^^^^^^^^^^
...
...
docs/topics/i18n/formatting.txt
Dosyayı görüntüle @
5abc811a
...
@@ -154,20 +154,11 @@ Django provides format definitions for many locales, but sometimes you might
...
@@ -154,20 +154,11 @@ Django provides format definitions for many locales, but sometimes you might
want to create your own, because a format files doesn't exist for your locale,
want to create your own, because a format files doesn't exist for your locale,
or because you want to overwrite some of the values.
or because you want to overwrite some of the values.
To use custom formats, specify the path where you'll place format files first.
To do that, just set your :setting:`FORMAT_MODULE_PATH` setting to the package
where format files will exist, for instance::
.. versionchanged:: 1.8
FORMAT_MODULE_PATH = 'mysite.formats'
The ability to specify FORMAT_MODULE_PATH as a list was added. Previously,
only a single string value was supported.
To use custom formats, specify the path where you'll place format files
first. To do that, just set your :setting:`FORMAT_MODULE_PATH` setting to
the package where format files will exist, for instance::
FORMAT_MODULE_PATH = [
'mysite.formats',
'some_app.formats',
]
Files are not placed directly in this directory, but in a directory named as
Files are not placed directly in this directory, but in a directory named as
the locale, and must be named ``formats.py``.
the locale, and must be named ``formats.py``.
...
...
tests/utils_tests/test_formats.py
deleted
100644 → 0
Dosyayı görüntüle @
a1f0c4c6
"""Tests for ``django/utils/formats.py``."""
from
django.test
import
TestCase
from
django.utils.formats
import
iter_format_modules
class
IterFormatModulesTestCase
(
TestCase
):
"""Tests for the ``iter_format_modules`` method."""
longMessage
=
True
def
test_returns_correct_default
(
self
):
"""
Should return default module when FORMAT_MODULE_PATH is not set.
"""
result
=
list
(
iter_format_modules
(
'en'
))
self
.
assertEqual
(
len
(
result
),
1
,
msg
=
(
"Should return only Django's default formats module."
))
self
.
assertEqual
(
result
[
0
]
.
__name__
,
'django.conf.locale.en.formats'
,
msg
=
(
'Should have added the language to the module path'
))
def
test_with_setting_as_basestring
(
self
):
"""
Before ticket #20477 FORMAT_MODULE_PATH was supposed to be a string.
This test ensures backwards compatibility.
"""
with
self
.
settings
(
FORMAT_MODULE_PATH
=
'utils_tests.test_module.formats'
):
result
=
list
(
iter_format_modules
(
'en'
))
self
.
assertEqual
(
len
(
result
),
2
,
msg
=
(
'Should return both, the default value and the one from the'
' setting'
))
self
.
assertEqual
(
result
[
0
]
.
__name__
,
'utils_tests.test_module.formats.en.formats'
,
msg
=
(
'Should return the module from the setting first and'
' should have added the language to the module path'
))
def
test_with_setting_as_list_of_strings
(
self
):
"""
After ticket #20477 FORMAT_MODULE_PATH can also be a list of strings.
This tests verifies the new functionality.
"""
FORMAT_MODULE_PATH
=
[
'utils_tests.test_module.formats'
,
'utils_tests.test_module.formats2'
,
]
with
self
.
settings
(
FORMAT_MODULE_PATH
=
FORMAT_MODULE_PATH
):
result
=
list
(
iter_format_modules
(
'en'
))
self
.
assertEqual
(
len
(
result
),
3
,
msg
=
(
'Should return the default value and the two values from the'
' setting'
))
self
.
assertEqual
(
result
[
0
]
.
__name__
,
'utils_tests.test_module.formats.en.formats'
,
msg
=
(
'Should return the values from the setting and add the'
' language to the module path'
))
tests/utils_tests/test_module/formats/__init__.py
deleted
100644 → 0
Dosyayı görüntüle @
a1f0c4c6
"""
Custom format module. Used by tests in ``tests/utils_tests/test_formats.py``.
"""
tests/utils_tests/test_module/formats/en/__init__.py
deleted
100644 → 0
Dosyayı görüntüle @
a1f0c4c6
tests/utils_tests/test_module/formats/en/formats.py
deleted
100644 → 0
Dosyayı görüntüle @
a1f0c4c6
tests/utils_tests/test_module/formats2/__init__.py
deleted
100644 → 0
Dosyayı görüntüle @
a1f0c4c6
tests/utils_tests/test_module/formats2/en/__init__.py
deleted
100644 → 0
Dosyayı görüntüle @
a1f0c4c6
tests/utils_tests/test_module/formats2/en/formats.py
deleted
100644 → 0
Dosyayı görüntüle @
a1f0c4c6
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment