24.4 Fixtures
A fixture is simply a file with data built to be loaded in the database. Django allows for serialization of data (putting data into a flat file for storage) into JSON or XML out of the box, but it can also use YAML if the PyYAML package is installed.
The utility of fixtures is broad because they become useful anytime you need data outside of the database. When we switched to a new User model in Chapter 22, had we had a production database, one approach to the problem would have been to serialize our data, modify the JSON, and then load the data into a restructured database. If we needed to pass data to another developer for testing purposes, or any other internal use, fixtures would be the solution.
By default, Django looks for ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access