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
34d88944
Kaydet (Commit)
34d88944
authored
Kas 25, 2015
tarafından
Gagaro
Kaydeden (comit)
Tim Graham
Kas 28, 2015
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Fixed #25812 -- Restored the ability to use custom formats with the date template filter.
üst
ab33269b
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
19 additions
and
6 deletions
+19
-6
AUTHORS
AUTHORS
+1
-0
formats.py
django/utils/formats.py
+3
-5
1.8.8.txt
docs/releases/1.8.8.txt
+4
-0
formatting.txt
docs/topics/i18n/formatting.txt
+4
-1
__init__.py
tests/i18n/other/locale/fr/__init__.py
+0
-0
formats.py
tests/i18n/other/locale/fr/formats.py
+2
-0
tests.py
tests/i18n/tests.py
+5
-0
No files found.
AUTHORS
Dosyayı görüntüle @
34d88944
...
...
@@ -749,6 +749,7 @@ answer newbie questions, and generally made Django that much better:
Wilson Miner <wminer@gmail.com>
wojtek
Xia Kai <http://blog.xiaket.org/>
Yann Fouillat <gagaro42@gmail.com>
Yann Malet
Yasushi Masuda <whosaysni@gmail.com>
ye7cakf02@sneakemail.com
...
...
django/utils/formats.py
Dosyayı görüntüle @
34d88944
...
...
@@ -110,8 +110,6 @@ def get_format(format_type, lang=None, use_l10n=None):
be localized (or not), overriding the value of settings.USE_L10N.
"""
format_type
=
force_str
(
format_type
)
if
format_type
not
in
FORMAT_SETTINGS
:
return
format_type
if
use_l10n
or
(
use_l10n
is
None
and
settings
.
USE_L10N
):
if
lang
is
None
:
lang
=
get_language
()
...
...
@@ -120,9 +118,6 @@ def get_format(format_type, lang=None, use_l10n=None):
cached
=
_format_cache
[
cache_key
]
if
cached
is
not
None
:
return
cached
else
:
# Return the general setting by default
return
getattr
(
settings
,
format_type
)
except
KeyError
:
for
module
in
get_format_modules
(
lang
):
try
:
...
...
@@ -137,6 +132,9 @@ def get_format(format_type, lang=None, use_l10n=None):
except
AttributeError
:
pass
_format_cache
[
cache_key
]
=
None
if
format_type
not
in
FORMAT_SETTINGS
:
return
format_type
# Return the general setting by default
return
getattr
(
settings
,
format_type
)
get_format_lazy
=
lazy
(
get_format
,
six
.
text_type
,
list
,
tuple
)
...
...
docs/releases/1.8.8.txt
Dosyayı görüntüle @
34d88944
...
...
@@ -14,3 +14,7 @@ Bugfixes
* Corrected ``__len`` query lookup on ``ArrayField`` for empty arrays
(:ticket:`25772`).
* Restored the ability to use custom formats from ``formats.py`` with
``django.utils.formats.get_format()`` and the ``date`` template filter
(:ticket:`25812`).
docs/topics/i18n/formatting.txt
Dosyayı görüntüle @
34d88944
...
...
@@ -164,7 +164,10 @@ the package where format files will exist, for instance::
]
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``. Be careful not to put sensitive
information in these files as values inside can be exposed if you pass the
string to ``django.utils.formats.get_format()`` (used by the :tfilter:`date`
template filter).
To customize the English formats, a structure like this would be needed::
...
...
tests/i18n/other/locale/fr/__init__.py
0 → 100644
Dosyayı görüntüle @
34d88944
tests/i18n/other/locale/fr/formats.py
0 → 100644
Dosyayı görüntüle @
34d88944
# A user-defined format
CUSTOM_DAY_FORMAT
=
'd/m/Y CUSTOM'
tests/i18n/tests.py
Dosyayı görüntüle @
34d88944
...
...
@@ -1252,6 +1252,11 @@ class FormattingTests(SimpleTestCase):
def
test_format_arbitrary_settings
(
self
):
self
.
assertEqual
(
get_format
(
'DEBUG'
),
'DEBUG'
)
def
test_get_custom_format
(
self
):
with
self
.
settings
(
FORMAT_MODULE_PATH
=
'i18n.other.locale'
):
with
translation
.
override
(
'fr'
,
deactivate
=
True
):
self
.
assertEqual
(
'd/m/Y CUSTOM'
,
get_format
(
'CUSTOM_DAY_FORMAT'
))
class
MiscTests
(
SimpleTestCase
):
...
...
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