O'Reilly logo

Django Unleashed by Andrew Pinkham

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required