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
20a91cce
Kaydet (Commit)
20a91cce
authored
Mar 17, 2013
tarafından
Aymeric Augustin
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Fixed #17037 -- Added a --all option to diffsettings.
üst
68905695
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
31 additions
and
6 deletions
+31
-6
diffsettings.py
django/core/management/commands/diffsettings.py
+13
-3
django-admin.txt
docs/ref/django-admin.txt
+5
-2
1.6.txt
docs/releases/1.6.txt
+2
-0
tests.py
tests/admin_scripts/tests.py
+11
-1
No files found.
django/core/management/commands/diffsettings.py
Dosyayı görüntüle @
20a91cce
from
optparse
import
make_option
from
django.core.management.base
import
NoArgsCommand
def
module_to_dict
(
module
,
omittable
=
lambda
k
:
k
.
startswith
(
'_'
)):
"
Converts a module namespace to a Python dictionary. Used by get_settings_diff.
"
return
dict
(
[(
k
,
repr
(
v
))
for
k
,
v
in
module
.
__dict__
.
items
()
if
not
omittable
(
k
)]
)
"
""Converts a module namespace to a Python dictionary.""
"
return
dict
(
(
k
,
repr
(
v
))
for
k
,
v
in
module
.
__dict__
.
items
()
if
not
omittable
(
k
)
)
class
Command
(
NoArgsCommand
):
help
=
"""Displays differences between the current settings.py and Django's
default settings. Settings that don't appear in the defaults are
followed by "###"."""
option_list
=
NoArgsCommand
.
option_list
+
(
make_option
(
'--all'
,
action
=
'store_true'
,
dest
=
'all'
,
default
=
False
,
help
=
'Display all settings, regardless of their value. '
'Default values are prefixed by "###".'
),
)
requires_model_validation
=
False
def
handle_noargs
(
self
,
**
options
):
...
...
@@ -22,9 +30,11 @@ class Command(NoArgsCommand):
default_settings
=
module_to_dict
(
global_settings
)
output
=
[]
for
key
in
sorted
(
user_settings
.
keys
()
):
for
key
in
sorted
(
user_settings
):
if
key
not
in
default_settings
:
output
.
append
(
"
%
s =
%
s ###"
%
(
key
,
user_settings
[
key
]))
elif
user_settings
[
key
]
!=
default_settings
[
key
]:
output
.
append
(
"
%
s =
%
s"
%
(
key
,
user_settings
[
key
]))
elif
options
[
'all'
]:
output
.
append
(
"###
%
s =
%
s"
%
(
key
,
user_settings
[
key
]))
return
'
\n
'
.
join
(
output
)
docs/ref/django-admin.txt
Dosyayı görüntüle @
20a91cce
...
...
@@ -168,8 +168,11 @@ example, the default settings don't define :setting:`ROOT_URLCONF`, so
:setting:`ROOT_URLCONF` is followed by ``"###"`` in the output of
``diffsettings``.
Note that Django's default settings live in ``django/conf/global_settings.py``,
if you're ever curious to see the full list of defaults.
The :djadminopt:`--all` option may be provided to display all settings, even
if they have Django's default value. Such settings are prefixed by ``"###"``.
.. versionadded:: 1.6
The :djadminopt:`--all` option was added.
dumpdata <appname appname appname.Model ...>
--------------------------------------------
...
...
docs/releases/1.6.txt
Dosyayı görüntüle @
20a91cce
...
...
@@ -157,6 +157,8 @@ Minor features
* The documentation contains a :doc:`deployment checklist
</howto/deployment/checklist>`.
* The :djadmin:`diffsettings` comand gained a ``--all`` option.
Backwards incompatible changes in 1.6
=====================================
...
...
tests/admin_scripts/tests.py
Dosyayı görüntüle @
20a91cce
...
...
@@ -1661,11 +1661,21 @@ class StartProject(LiveServerTestCase, AdminScriptTestCase):
class
DiffSettings
(
AdminScriptTestCase
):
"""Tests for diffsettings management command."""
def
test_basic
(
self
):
"
Runs without error and emits settings diff.
"
"
""Runs without error and emits settings diff.""
"
self
.
write_settings
(
'settings_to_diff.py'
,
sdict
=
{
'FOO'
:
'"bar"'
})
self
.
addCleanup
(
self
.
remove_settings
,
'settings_to_diff.py'
)
args
=
[
'diffsettings'
,
'--settings=settings_to_diff'
]
out
,
err
=
self
.
run_manage
(
args
)
self
.
assertNoOutput
(
err
)
self
.
assertOutput
(
out
,
"FOO = 'bar' ###"
)
def
test_all
(
self
):
"""The all option also shows settings with the default value."""
self
.
write_settings
(
'settings_to_diff.py'
,
sdict
=
{
'STATIC_URL'
:
'None'
})
self
.
addCleanup
(
self
.
remove_settings
,
'settings_to_diff.py'
)
args
=
[
'diffsettings'
,
'--settings=settings_to_diff'
,
'--all'
]
out
,
err
=
self
.
run_manage
(
args
)
self
.
assertNoOutput
(
err
)
self
.
assertOutput
(
out
,
"### STATIC_URL = None"
)
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