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
67235fd4
Kaydet (Commit)
67235fd4
authored
Ara 26, 2014
tarafından
Tim Graham
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Removed support for initial_data fixtures per deprecation timeline.
üst
f635d759
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
21 changed files
with
9 additions
and
211 deletions
+9
-211
flush.py
django/core/management/commands/flush.py
+1
-16
loaddata.py
django/core/management/commands/loaddata.py
+1
-7
migrate.py
django/core/management/commands/migrate.py
+0
-12
initial-data.txt
docs/howto/initial-data.txt
+0
-15
django-admin.txt
docs/ref/django-admin.txt
+0
-6
overview.txt
docs/topics/testing/overview.txt
+0
-5
tools.txt
docs/topics/testing/tools.txt
+0
-12
initial_data.json
tests/fixtures/fixtures/initial_data.json
+0
-9
tests.py
tests/fixtures/tests.py
+0
-0
__init__.py
tests/fixtures_migration/__init__.py
+0
-0
initial_data.json
tests/fixtures_migration/fixtures/initial_data.json
+0
-9
0001_initial.py
tests/fixtures_migration/migrations/0001_initial.py
+0
-16
__init__.py
tests/fixtures_migration/migrations/__init__.py
+0
-0
models.py
tests/fixtures_migration/models.py
+0
-5
tests.py
tests/fixtures_migration/tests.py
+0
-31
initial_data.json
tests/fixtures_model_package/fixtures/initial_data.json
+0
-9
tests.py
tests/fixtures_model_package/tests.py
+2
-47
tests.py
tests/migrate_signals/tests.py
+2
-2
tests.py
tests/multiple_database/tests.py
+2
-4
runtests.py
tests/runtests.py
+0
-5
tests.py
tests/swappable_models/tests.py
+1
-1
No files found.
django/core/management/commands/flush.py
Dosyayı görüntüle @
67235fd4
...
...
@@ -5,7 +5,6 @@ from importlib import import_module
from
django.apps
import
apps
from
django.db
import
connections
,
router
,
transaction
,
DEFAULT_DB_ALIAS
from
django.core.management
import
call_command
from
django.core.management.base
import
BaseCommand
,
CommandError
from
django.core.management.color
import
no_style
from
django.core.management.sql
import
sql_flush
,
emit_post_migrate_signal
...
...
@@ -15,8 +14,7 @@ from django.utils import six
class
Command
(
BaseCommand
):
help
=
(
'Removes ALL DATA from the database, including data added during '
'migrations. Unmigrated apps will also have their initial_data '
'fixture reloaded. Does not achieve a "fresh install" state.'
)
'migrations. Does not achieve a "fresh install" state.'
)
def
add_arguments
(
self
,
parser
):
parser
.
add_argument
(
'--noinput'
,
action
=
'store_false'
,
dest
=
'interactive'
,
default
=
True
,
...
...
@@ -24,9 +22,6 @@ class Command(BaseCommand):
parser
.
add_argument
(
'--database'
,
action
=
'store'
,
dest
=
'database'
,
default
=
DEFAULT_DB_ALIAS
,
help
=
'Nominates a database to flush. Defaults to the "default" database.'
)
parser
.
add_argument
(
'--no-initial-data'
,
action
=
'store_false'
,
dest
=
'load_initial_data'
,
default
=
True
,
help
=
'Tells Django not to load any initial data after database synchronization.'
)
def
handle
(
self
,
**
options
):
database
=
options
.
get
(
'database'
)
...
...
@@ -82,16 +77,6 @@ Are you sure you want to do this?
if
not
inhibit_post_migrate
:
self
.
emit_post_migrate
(
verbosity
,
interactive
,
database
)
# Reinstall the initial_data fixture.
if
options
.
get
(
'load_initial_data'
):
# 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
"
)
...
...
django/core/management/commands/loaddata.py
Dosyayı görüntüle @
67235fd4
...
...
@@ -18,7 +18,6 @@ from django.utils import lru_cache
from
django.utils.encoding
import
force_text
from
django.utils.functional
import
cached_property
from
django.utils._os
import
upath
from
django.utils.deprecation
import
RemovedInDjango19Warning
from
itertools
import
product
try
:
...
...
@@ -218,14 +217,9 @@ class Command(BaseCommand):
(
fixture_name
,
humanize
(
fixture_dir
)))
fixture_files
.
extend
(
fixture_files_in_dir
)
if
fixture_name
!=
'initial_data'
and
not
fixture_files
:
if
not
fixture_files
:
# Warning kept for backwards-compatibility; why not an exception?
warnings
.
warn
(
"No fixture named '
%
s' found."
%
fixture_name
)
elif
fixture_name
==
'initial_data'
and
fixture_files
:
warnings
.
warn
(
'initial_data fixtures are deprecated. Use data migrations instead.'
,
RemovedInDjango19Warning
)
return
fixture_files
...
...
django/core/management/commands/migrate.py
Dosyayı görüntüle @
67235fd4
...
...
@@ -35,8 +35,6 @@ class Command(BaseCommand):
)
parser
.
add_argument
(
'--noinput'
,
action
=
'store_false'
,
dest
=
'interactive'
,
default
=
True
,
help
=
'Tells Django to NOT prompt the user for input of any kind.'
)
parser
.
add_argument
(
'--no-initial-data'
,
action
=
'store_false'
,
dest
=
'load_initial_data'
,
default
=
True
,
help
=
'Tells Django not to load any initial data after database synchronization.'
)
parser
.
add_argument
(
'--database'
,
action
=
'store'
,
dest
=
'database'
,
default
=
DEFAULT_DB_ALIAS
,
help
=
'Nominates a database to synchronize. '
'Defaults to the "default" database.'
)
...
...
@@ -50,7 +48,6 @@ class Command(BaseCommand):
self
.
verbosity
=
options
.
get
(
'verbosity'
)
self
.
interactive
=
options
.
get
(
'interactive'
)
self
.
show_traceback
=
options
.
get
(
'traceback'
)
self
.
load_initial_data
=
options
.
get
(
'load_initial_data'
)
# Import the 'management' module within each installed app, to register
# dispatcher events.
...
...
@@ -339,13 +336,4 @@ class Command(BaseCommand):
finally
:
cursor
.
close
()
# Load initial_data fixtures (unless that has been disabled)
if
self
.
load_initial_data
:
for
app_label
in
app_labels
:
call_command
(
'loaddata'
,
'initial_data'
,
verbosity
=
self
.
verbosity
,
database
=
connection
.
alias
,
app_label
=
app_label
,
hide_empty
=
True
,
)
return
created_models
docs/howto/initial-data.txt
Dosyayı görüntüle @
67235fd4
...
...
@@ -76,21 +76,6 @@ from the fixture and re-loaded into the database. Note this means that if you
change one of the rows created by a fixture and then run :djadmin:`loaddata`
again, you'll wipe out any changes you've made.
Automatically loading initial data fixtures
-------------------------------------------
.. deprecated:: 1.7
If an application uses migrations, there is no automatic loading of
fixtures. Since migrations will be required for applications in Django 1.9,
this behavior is considered deprecated. If you want to load initial data
for an app, consider doing it in a :ref:`data migration <data-migrations>`.
If you create a fixture named ``initial_data.[xml/yaml/json]``, that fixture will
be loaded every time you run :djadmin:`migrate`. This is extremely convenient,
but be careful: remember that the data will be refreshed *every time* you run
:djadmin:`migrate`. So don't use ``initial_data`` for data you'll want to edit.
Where Django finds fixture files
--------------------------------
...
...
docs/ref/django-admin.txt
Dosyayı görüntüle @
67235fd4
...
...
@@ -341,12 +341,6 @@ prompts.
The :djadminopt:`--database` option may be used to specify the database
to flush.
``--no-initial-data``
~~~~~~~~~~~~~~~~~~~~~
Use ``--no-initial-data`` to avoid loading the initial_data fixture.
inspectdb
---------
...
...
docs/topics/testing/overview.txt
Dosyayı görüntüle @
67235fd4
...
...
@@ -260,9 +260,6 @@ The initial serialization is usually very quick, but if you wish to exclude
some apps from this process (and speed up test runs slightly), you may add
those apps to :setting:`TEST_NON_SERIALIZED_APPS`.
Apps without migrations are not affected; ``initial_data`` fixtures are
reloaded as usual.
Other test conditions
---------------------
...
...
@@ -288,8 +285,6 @@ prepares itself. You can control the level of detail of these messages with the
Creating test database...
Creating table myapp_animal
Creating table myapp_mineral
Loading 'initial_data' fixtures...
No fixtures found.
This tells you that the test runner is creating a test database, as described
in the previous section.
...
...
docs/topics/testing/tools.txt
Dosyayı görüntüle @
67235fd4
...
...
@@ -984,18 +984,6 @@ The most straightforward way of creating a fixture is to use the
already have some data in your database. See the :djadmin:`dumpdata
documentation<dumpdata>` for more details.
.. note::
If you've ever run :djadmin:`manage.py migrate<migrate>`, you've
already used a fixture without even knowing it! When you call
:djadmin:`migrate` in the database for the first time, Django
installs a fixture called ``initial_data``. This gives you a way
of populating a new database with any initial data, such as a
default set of categories.
Fixtures with other names can always be installed manually using
the :djadmin:`manage.py loaddata<loaddata>` command.
.. admonition:: Initial SQL data and testing
Django provides a second way to insert initial data into models --
...
...
tests/fixtures/fixtures/initial_data.json
deleted
100644 → 0
Dosyayı görüntüle @
f635d759
[
{
"pk"
:
"10"
,
"model"
:
"fixtures.book"
,
"fields"
:
{
"name"
:
"Achieving self-awareness of Python programs"
}
}
]
tests/fixtures/tests.py
Dosyayı görüntüle @
67235fd4
This diff is collapsed.
Click to expand it.
tests/fixtures_migration/__init__.py
deleted
100644 → 0
Dosyayı görüntüle @
f635d759
tests/fixtures_migration/fixtures/initial_data.json
deleted
100644 → 0
Dosyayı görüntüle @
f635d759
[
{
"pk"
:
"10"
,
"model"
:
"fixtures_migration.book"
,
"fields"
:
{
"name"
:
"Achieving self-awareness of Python programs"
}
}
]
tests/fixtures_migration/migrations/0001_initial.py
deleted
100644 → 0
Dosyayı görüntüle @
f635d759
# -*- 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
deleted
100644 → 0
Dosyayı görüntüle @
f635d759
tests/fixtures_migration/models.py
deleted
100644 → 0
Dosyayı görüntüle @
f635d759
from
django.db
import
models
class
Book
(
models
.
Model
):
name
=
models
.
CharField
(
max_length
=
100
)
tests/fixtures_migration/tests.py
deleted
100644 → 0
Dosyayı görüntüle @
f635d759
from
django.test
import
TransactionTestCase
from
django.core
import
management
from
.models
import
Book
class
TestNoInitialDataLoading
(
TransactionTestCase
):
"""
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
=
[
'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
(),
[])
tests/fixtures_model_package/fixtures/initial_data.json
deleted
100644 → 0
Dosyayı görüntüle @
f635d759
[
{
"pk"
:
"10"
,
"model"
:
"fixtures_model_package.book"
,
"fields"
:
{
"name"
:
"Achieving self-awareness of Python programs"
}
}
]
tests/fixtures_model_package/tests.py
Dosyayı görüntüle @
67235fd4
...
...
@@ -3,11 +3,10 @@ from __future__ import unicode_literals
import
warnings
from
django.core
import
management
from
django.db
import
transaction
from
django.test
import
TestCase
,
TransactionTestCase
from
django.test
import
TestCase
from
django.utils.six
import
StringIO
from
.models
import
Article
,
Book
from
.models
import
Article
class
SampleTestCase
(
TestCase
):
...
...
@@ -26,51 +25,7 @@ class SampleTestCase(TestCase):
)
class
TestNoInitialDataLoading
(
TransactionTestCase
):
available_apps
=
[
'fixtures_model_package'
]
def
test_migrate
(
self
):
with
transaction
.
atomic
():
Book
.
objects
.
all
()
.
delete
()
management
.
call_command
(
'migrate'
,
verbosity
=
0
,
load_initial_data
=
False
)
self
.
assertQuerysetEqual
(
Book
.
objects
.
all
(),
[])
def
test_flush
(
self
):
# Test presence of fixture (flush called by TransactionTestCase)
self
.
assertQuerysetEqual
(
Book
.
objects
.
all
(),
[
'Achieving self-awareness of Python programs'
],
lambda
a
:
a
.
name
)
with
transaction
.
atomic
():
management
.
call_command
(
'flush'
,
verbosity
=
0
,
interactive
=
False
,
load_initial_data
=
False
)
self
.
assertQuerysetEqual
(
Book
.
objects
.
all
(),
[])
class
FixtureTestCase
(
TestCase
):
def
test_initial_data
(
self
):
"Fixtures can load initial data into models defined in packages"
# migrate introduces 1 initial data object from initial_data.json
# this behavior is deprecated and will be removed in Django 1.9
self
.
assertQuerysetEqual
(
Book
.
objects
.
all
(),
[
'Achieving self-awareness of Python programs'
],
lambda
a
:
a
.
name
)
def
test_loaddata
(
self
):
"Fixtures can load data into models defined in packages"
...
...
tests/migrate_signals/tests.py
Dosyayı görüntüle @
67235fd4
...
...
@@ -66,7 +66,7 @@ class MigrateSignalTests(TestCase):
signals
.
pre_migrate
.
connect
(
r
,
sender
=
APP_CONFIG
)
management
.
call_command
(
'migrate'
,
database
=
MIGRATE_DATABASE
,
verbosity
=
MIGRATE_VERBOSITY
,
interactive
=
MIGRATE_INTERACTIVE
,
load_initial_data
=
False
,
stdout
=
six
.
StringIO
())
stdout
=
six
.
StringIO
())
args
=
r
.
call_args
self
.
assertEqual
(
r
.
call_counter
,
1
)
...
...
@@ -86,7 +86,7 @@ class MigrateSignalTests(TestCase):
stdout
=
six
.
StringIO
()
management
.
call_command
(
'migrate'
,
database
=
MIGRATE_DATABASE
,
verbosity
=
MIGRATE_VERBOSITY
,
interactive
=
MIGRATE_INTERACTIVE
,
load_initial_data
=
False
,
stdout
=
stdout
)
stdout
=
stdout
)
args
=
r
.
call_args
self
.
assertEqual
(
r
.
call_counter
,
1
)
self
.
assertEqual
(
set
(
args
),
set
(
PRE_MIGRATE_ARGS
))
...
...
tests/multiple_database/tests.py
Dosyayı görüntüle @
67235fd4
...
...
@@ -1778,8 +1778,7 @@ class MigrateTestCase(TestCase):
self
.
assertGreater
(
count
,
0
)
cts
.
delete
()
management
.
call_command
(
'migrate'
,
verbosity
=
0
,
interactive
=
False
,
load_initial_data
=
False
,
database
=
'other'
)
management
.
call_command
(
'migrate'
,
verbosity
=
0
,
interactive
=
False
,
database
=
'other'
)
self
.
assertEqual
(
cts
.
count
(),
count
)
def
test_migrate_to_other_database_with_router
(
self
):
...
...
@@ -1788,8 +1787,7 @@ class MigrateTestCase(TestCase):
cts
.
delete
()
with
override_settings
(
DATABASE_ROUTERS
=
[
SyncOnlyDefaultDatabaseRouter
()]):
management
.
call_command
(
'migrate'
,
verbosity
=
0
,
interactive
=
False
,
load_initial_data
=
False
,
database
=
'other'
)
management
.
call_command
(
'migrate'
,
verbosity
=
0
,
interactive
=
False
,
database
=
'other'
)
self
.
assertEqual
(
cts
.
count
(),
0
)
...
...
tests/runtests.py
Dosyayı görüntüle @
67235fd4
...
...
@@ -239,11 +239,6 @@ def django_tests(verbosity, interactive, failfast, keepdb, reverse, test_labels,
"use '<app_label>/sql' instead."
,
RemovedInDjango19Warning
)
warnings
.
filterwarnings
(
'ignore'
,
'initial_data fixtures are deprecated. Use data migrations instead.'
,
RemovedInDjango19Warning
)
failures
=
test_runner
.
run_tests
(
test_labels
or
get_installed
(),
extra_tests
=
extra_tests
)
...
...
tests/swappable_models/tests.py
Dosyayı görüntüle @
67235fd4
...
...
@@ -28,7 +28,7 @@ class SwappableModelTests(TestCase):
# Re-run migrate. This will re-build the permissions and content types.
new_io
=
StringIO
()
management
.
call_command
(
'migrate'
,
load_initial_data
=
False
,
interactive
=
False
,
stdout
=
new_io
)
management
.
call_command
(
'migrate'
,
interactive
=
False
,
stdout
=
new_io
)
# Check that content types and permissions exist for the swapped model,
# but not for the swappable model.
...
...
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