summaryrefslogtreecommitdiff
path: root/docs/howto
diff options
context:
space:
mode:
authorTim Graham <timograham@gmail.com>2018-03-08 10:58:19 -0500
committerTim Graham <timograham@gmail.com>2018-03-08 10:58:35 -0500
commit8d3bd724ab996078a570dd736b85a8ad5b317f97 (patch)
tree622fadd32a0d4273567d2371554ea4349313e6af /docs/howto
parent564847fc1f493cd81063d7313765bdb4c28e0884 (diff)
[2.0.x] Fixed #29165 -- Clarified how to load initial data with migrations.
Backport of fd9398816e14554b52362f1152349da832fab4b1 from master
Diffstat (limited to 'docs/howto')
-rw-r--r--docs/howto/initial-data.txt27
1 files changed, 15 insertions, 12 deletions
diff --git a/docs/howto/initial-data.txt b/docs/howto/initial-data.txt
index 0568d36262..64012f66b9 100644
--- a/docs/howto/initial-data.txt
+++ b/docs/howto/initial-data.txt
@@ -3,13 +3,24 @@ Providing initial data for models
=================================
It's sometimes useful to pre-populate your database with hard-coded data when
-you're first setting up an app. You can provide initial data with fixtures or
-migrations.
+you're first setting up an app. You can provide initial data with migrations or
+fixtures.
+
+Providing initial data with migrations
+======================================
+
+If you want to automatically load initial data for an app, create a
+:ref:`data migration <data-migrations>`. Migrations are run when setting up the
+test database, so the data will be available there, subject to :ref:`some
+limitations <test-case-serialized-rollback>`.
.. _initial-data-via-fixtures:
-Providing initial data with fixtures
-====================================
+Providing data with fixtures
+============================
+
+You can also provide data using fixtures, however, this data isn't loaded
+automatically, except if you use :attr:`.TransactionTestCase.fixtures`.
A fixture is a collection of data that Django knows how to import into a
database. The most straightforward way of creating a fixture if you've already
@@ -84,11 +95,3 @@ directories.
Fixtures are also used by the :ref:`testing framework
<topics-testing-fixtures>` to help set up a consistent test environment.
-
-Providing initial data with migrations
-======================================
-
-If you want to automatically load initial data for an app, don't use fixtures.
-Instead, create a migration for your application with
-:class:`~django.db.migrations.operations.RunPython` or
-:class:`~django.db.migrations.operations.RunSQL` operations.