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
96c71d42
Kaydet (Commit)
96c71d42
authored
Haz 09, 2013
tarafından
Tim Graham
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Added runserver validation to detect if DEBUG=False and ALLOWED_HOSTS is empty.
Refs #19875.
üst
4e94c84e
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
0 deletions
+20
-0
runserver.py
django/core/management/commands/runserver.py
+5
-0
tests.py
tests/admin_scripts/tests.py
+15
-0
No files found.
django/core/management/commands/runserver.py
Dosyayı görüntüle @
96c71d42
...
...
@@ -40,6 +40,11 @@ class Command(BaseCommand):
return
get_internal_wsgi_application
()
def
handle
(
self
,
addrport
=
''
,
*
args
,
**
options
):
from
django.conf
import
settings
if
not
settings
.
DEBUG
and
not
settings
.
ALLOWED_HOSTS
:
raise
CommandError
(
'You must set settings.ALLOWED_HOSTS if DEBUG is False.'
)
self
.
use_ipv6
=
options
.
get
(
'use_ipv6'
)
if
self
.
use_ipv6
and
not
socket
.
has_ipv6
:
raise
CommandError
(
'Your Python does not support IPv6.'
)
...
...
tests/admin_scripts/tests.py
Dosyayı görüntüle @
96c71d42
...
...
@@ -1192,6 +1192,21 @@ class ManageRunserver(AdminScriptTestCase):
self
.
cmd
.
handle
(
addrport
=
"deadbeef:7654"
)
self
.
assertServerSettings
(
'deadbeef'
,
'7654'
)
class
ManageRunserverEmptyAllowedHosts
(
AdminScriptTestCase
):
def
setUp
(
self
):
self
.
write_settings
(
'settings.py'
,
sdict
=
{
'ALLOWED_HOSTS'
:
[],
'DEBUG'
:
False
,
})
def
tearDown
(
self
):
self
.
remove_settings
(
'settings.py'
)
def
test_empty_allowed_hosts_error
(
self
):
out
,
err
=
self
.
run_manage
([
'runserver'
])
self
.
assertNoOutput
(
out
)
self
.
assertOutput
(
err
,
'CommandError: You must set settings.ALLOWED_HOSTS if DEBUG is False.'
)
##########################################################################
# COMMAND PROCESSING TESTS
...
...
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