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 ...
Get Django Unleashed now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.