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
e8cf4f8a
Kaydet (Commit)
e8cf4f8a
authored
Şub 12, 2015
tarafından
Tim Graham
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Fixed #24332 -- Fixed contrib.sites create_default_site() when 'default' DATABASES is empty.
üst
bd4afef9
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
34 additions
and
4 deletions
+34
-4
management.py
django/contrib/sites/management.py
+1
-1
models.py
django/contrib/sites/models.py
+2
-1
1.7.5.txt
docs/releases/1.7.5.txt
+3
-0
tests.py
tests/sites_tests/tests.py
+28
-2
No files found.
django/contrib/sites/management.py
Dosyayı görüntüle @
e8cf4f8a
...
...
@@ -17,7 +17,7 @@ def create_default_site(app_config, verbosity=2, interactive=True, using=DEFAULT
if
not
router
.
allow_migrate
(
using
,
Site
):
return
if
not
Site
.
objects
.
exists
():
if
not
Site
.
objects
.
using
(
using
)
.
exists
():
# The default settings set SITE_ID = 1, and some tests in Django's test
# suite rely on this value. However, if database sequences are reused
# (e.g. in the test suite after flush/syncdb), it isn't guaranteed that
...
...
django/contrib/sites/models.py
Dosyayı görüntüle @
e8cf4f8a
...
...
@@ -92,12 +92,13 @@ def clear_site_cache(sender, **kwargs):
Clears the cache (if primed) each time a site is saved or deleted
"""
instance
=
kwargs
[
'instance'
]
using
=
kwargs
[
'using'
]
try
:
del
SITE_CACHE
[
instance
.
pk
]
except
KeyError
:
pass
try
:
del
SITE_CACHE
[
Site
.
objects
.
get
(
pk
=
instance
.
pk
)
.
domain
]
del
SITE_CACHE
[
Site
.
objects
.
using
(
using
)
.
get
(
pk
=
instance
.
pk
)
.
domain
]
except
(
KeyError
,
Site
.
DoesNotExist
):
pass
pre_save
.
connect
(
clear_site_cache
,
sender
=
Site
)
...
...
docs/releases/1.7.5.txt
Dosyayı görüntüle @
e8cf4f8a
...
...
@@ -16,3 +16,6 @@ Bugfixes
* Fixed a regression that prevented custom fields inheriting from
``ManyToManyField`` from being recognized in migrations (:ticket:`24236`).
* Fixed crash in ``contrib.sites`` migrations when a default database isn't
used (:ticket:`24332`).
tests/sites_tests/tests.py
Dosyayı görüntüle @
e8cf4f8a
...
...
@@ -17,6 +17,7 @@ from django.test.utils import captured_stdout
@modify_settings
(
INSTALLED_APPS
=
{
'append'
:
'django.contrib.sites'
})
class
SitesFrameworkTests
(
TestCase
):
multi_db
=
True
def
setUp
(
self
):
self
.
site
=
Site
(
...
...
@@ -112,7 +113,26 @@ class SitesFrameworkTests(TestCase):
expected_cache
.
update
({
self
.
site
.
domain
:
self
.
site
})
self
.
assertEqual
(
models
.
SITE_CACHE
,
expected_cache
)
clear_site_cache
(
Site
,
instance
=
self
.
site
)
clear_site_cache
(
Site
,
instance
=
self
.
site
,
using
=
'default'
)
self
.
assertEqual
(
models
.
SITE_CACHE
,
{})
@override_settings
(
SITE_ID
=
''
)
def
test_clear_site_cache_domain
(
self
):
site
=
Site
.
objects
.
create
(
name
=
'example2.com'
,
domain
=
'example2.com'
)
request
=
HttpRequest
()
request
.
META
=
{
"SERVER_NAME"
:
"example2.com"
,
"SERVER_PORT"
:
"80"
,
}
get_current_site
(
request
)
# prime the models.SITE_CACHE
expected_cache
=
{
site
.
domain
:
site
}
self
.
assertEqual
(
models
.
SITE_CACHE
,
expected_cache
)
# Site exists in 'default' database so using='other' shouldn't clear.
clear_site_cache
(
Site
,
instance
=
site
,
using
=
'other'
)
self
.
assertEqual
(
models
.
SITE_CACHE
,
expected_cache
)
# using='default' should clear.
clear_site_cache
(
Site
,
instance
=
site
,
using
=
'default'
)
self
.
assertEqual
(
models
.
SITE_CACHE
,
{})
...
...
@@ -146,7 +166,7 @@ class CreateDefaultSiteTests(TestCase):
self
.
assertEqual
(
""
,
stdout
.
getvalue
())
@override_settings
(
DATABASE_ROUTERS
=
[
JustOtherRouter
()])
def
test_multi_db
(
self
):
def
test_multi_db
_with_router
(
self
):
"""
#16353, #16828 - The default site creation should respect db routing.
"""
...
...
@@ -155,6 +175,12 @@ class CreateDefaultSiteTests(TestCase):
self
.
assertFalse
(
Site
.
objects
.
using
(
'default'
)
.
exists
())
self
.
assertTrue
(
Site
.
objects
.
using
(
'other'
)
.
exists
())
def
test_multi_db
(
self
):
create_default_site
(
self
.
app_config
,
using
=
'default'
,
verbosity
=
0
)
create_default_site
(
self
.
app_config
,
using
=
'other'
,
verbosity
=
0
)
self
.
assertTrue
(
Site
.
objects
.
using
(
'default'
)
.
exists
())
self
.
assertTrue
(
Site
.
objects
.
using
(
'other'
)
.
exists
())
def
test_save_another
(
self
):
"""
#17415 - Another site can be created right after the default one.
...
...
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