Importing data from a data fixture
Importing data from a fixture is done using the loaddata
Django management command. As long as data exists in one of the four file formats, JSON, JSONL, XML, or YAML, it can be imported using this command. Data can be imported even if it was not exported from a Django project. The loaddata
management command does not have as many options as the dumpdata
command uses but they do share most of the same options.
We have been using this command throughout most of this book to ensure that we have test data available when working with the exercises of previous chapters. Instead of going through examples of how to use this command in depth, we will briefly remind ourselves how it is used and then describe each of the options that are available and what they are used for.
Using the importdata command
Follow these steps to practice loading the /chapter_10/fixtures/chapter_3_sellers.json
fixture file that we created earlier in this chapter. If we...