4
4
Fixtures
5
5
========
6
6
7
- .. seealso::
8
-
9
- * :doc:`/howto/initial-data`
10
-
11
- What is a fixture?
12
- ==================
13
-
14
7
A *fixture* is a collection of files that contain the serialized contents of
15
8
the database. Each fixture has a unique name, and the files that comprise the
16
9
fixture can be distributed over multiple directories, in multiple applications.
17
10
18
- How to produce a fixture?
19
- =========================
11
+ .. seealso::
12
+
13
+ * :doc:`/howto/initial-data`
14
+
15
+ How to produce a fixture
16
+ ========================
20
17
21
18
Fixtures can be generated by :djadmin:`manage.py dumpdata <dumpdata>`. It's
22
19
also possible to generate custom fixtures by directly using :doc:`serialization
23
20
tools </topics/serialization>` or even by handwriting them.
24
21
25
- How to use a fixture?
26
- =====================
22
+ How to use a fixture
23
+ ====================
27
24
28
- Fixtures can be used to pre-populate database with data for
25
+ Fixtures can be used to pre-populate the database with data for
29
26
:ref:`tests <topics-testing-fixtures>`:
30
27
31
28
.. code-block:: python
@@ -40,8 +37,8 @@ or to provide some :ref:`initial data <initial-data-via-fixtures>` using the
40
37
41
38
django-admin loaddata <fixture label>
42
39
43
- Where Django looks for fixtures?
44
- ================================
40
+ How fixtures are discovered
41
+ ===========================
45
42
46
43
Django will search in these locations for fixtures:
47
44
@@ -116,8 +113,8 @@ example).
116
113
117
114
.. _MySQL: https://dev.mysql.com/doc/refman/en/constraint-foreign-key.html
118
115
119
- How fixtures are saved to the database?
120
- =======================================
116
+ How fixtures are saved to the database
117
+ ======================================
121
118
122
119
When fixture files are processed, the data is saved to the database as is.
123
120
Model defined :meth:`~django.db.models.Model.save` methods are not called, and
0 commit comments