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
5cc8180a
Kaydet (Commit)
5cc8180a
authored
Eki 27, 2014
tarafından
Tim Graham
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
[1.7.x] Fixed #23699 -- Prevented flush from loading initial data for apps with migrations.
Backport of
dd1ea707
from master.
üst
e317d7fc
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
71 additions
and
3 deletions
+71
-3
flush.py
django/core/management/commands/flush.py
+7
-3
1.7.2.txt
docs/releases/1.7.2.txt
+3
-0
__init__.py
tests/fixtures_migration/__init__.py
+0
-0
initial_data.json
tests/fixtures_migration/fixtures/initial_data.json
+9
-0
0001_initial.py
tests/fixtures_migration/migrations/0001_initial.py
+16
-0
__init__.py
tests/fixtures_migration/migrations/__init__.py
+0
-0
models.py
tests/fixtures_migration/models.py
+5
-0
tests.py
tests/fixtures_migration/tests.py
+31
-0
No files found.
django/core/management/commands/flush.py
Dosyayı görüntüle @
5cc8180a
...
...
@@ -84,9 +84,13 @@ Are you sure you want to do this?
# Reinstall the initial_data fixture.
if
options
.
get
(
'load_initial_data'
):
# Reinstall the initial_data fixture.
call_command
(
'loaddata'
,
'initial_data'
,
**
options
)
# Reinstall the initial_data fixture for apps without migrations.
from
django.db.migrations.executor
import
MigrationExecutor
executor
=
MigrationExecutor
(
connection
)
app_options
=
options
.
copy
()
for
app_label
in
executor
.
loader
.
unmigrated_apps
:
app_options
[
'app_label'
]
=
app_label
call_command
(
'loaddata'
,
'initial_data'
,
**
app_options
)
else
:
self
.
stdout
.
write
(
"Flush cancelled.
\n
"
)
...
...
docs/releases/1.7.2.txt
Dosyayı görüntüle @
5cc8180a
...
...
@@ -18,3 +18,6 @@ Bugfixes
* Warn for duplicate models when a module is reloaded. Previously a
RuntimeError was raised every time two models clashed in the app registry.
(:ticket:`23621`).
* Prevented :djadmin:`flush` from loading initial data for migrated apps
(:ticket:`23699`).
tests/fixtures_migration/__init__.py
0 → 100644
Dosyayı görüntüle @
5cc8180a
tests/fixtures_migration/fixtures/initial_data.json
0 → 100644
Dosyayı görüntüle @
5cc8180a
[
{
"pk"
:
"10"
,
"model"
:
"fixtures_migration.book"
,
"fields"
:
{
"name"
:
"Achieving self-awareness of Python programs"
}
}
]
tests/fixtures_migration/migrations/0001_initial.py
0 → 100644
Dosyayı görüntüle @
5cc8180a
# -*- coding: utf-8 -*-
from
__future__
import
unicode_literals
from
django.db
import
migrations
,
models
class
Migration
(
migrations
.
Migration
):
operations
=
[
migrations
.
CreateModel
(
"Book"
,
[
(
"name"
,
models
.
CharField
(
max_length
=
100
)),
],
),
]
tests/fixtures_migration/migrations/__init__.py
0 → 100644
Dosyayı görüntüle @
5cc8180a
tests/fixtures_migration/models.py
0 → 100644
Dosyayı görüntüle @
5cc8180a
from
django.db
import
models
class
Book
(
models
.
Model
):
name
=
models
.
CharField
(
max_length
=
100
)
tests/fixtures_migration/tests.py
0 → 100644
Dosyayı görüntüle @
5cc8180a
from
django.test
import
TestCase
from
django.core
import
management
from
.models
import
Book
class
TestNoInitialDataLoading
(
TestCase
):
"""
Apps with migrations should ignore initial data. This test can be removed
in Django 1.9 when migrations become required and initial data is no longer
supported.
"""
available_apps
=
[
'django.contrib.auth'
,
'django.contrib.contenttypes'
,
'fixtures_migration'
]
def
test_migrate
(
self
):
self
.
assertQuerysetEqual
(
Book
.
objects
.
all
(),
[])
management
.
call_command
(
'migrate'
,
verbosity
=
0
,
)
self
.
assertQuerysetEqual
(
Book
.
objects
.
all
(),
[])
def
test_flush
(
self
):
self
.
assertQuerysetEqual
(
Book
.
objects
.
all
(),
[])
management
.
call_command
(
'flush'
,
verbosity
=
0
,
interactive
=
False
,
load_initial_data
=
False
)
self
.
assertQuerysetEqual
(
Book
.
objects
.
all
(),
[])
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