| 83 | 84 | >>> management.call_command('dumpdata', 'fixtures', format='json') |
|---|
| 84 | 85 | [{"pk": 3, "model": "fixtures.article", "fields": {"headline": "Time to reform copyright", "pub_date": "2006-06-16 13:00:00"}}, {"pk": 2, "model": "fixtures.article", "fields": {"headline": "Poker has no place on ESPN", "pub_date": "2006-06-16 12:00:00"}}, {"pk": 1, "model": "fixtures.article", "fields": {"headline": "Python program becomes self aware", "pub_date": "2006-06-16 11:00:00"}}] |
|---|
| | 86 | |
|---|
| | 87 | # Load fixture 4 (compressed), using format discovery |
|---|
| | 88 | >>> management.call_command('loaddata', 'fixture4', verbosity=0) |
|---|
| | 89 | >>> Article.objects.all() |
|---|
| | 90 | [<Article: Django pets kitten>, <Article: Time to reform copyright>, <Article: Poker has no place on ESPN>, <Article: Python program becomes self aware>] |
|---|
| | 91 | |
|---|
| | 92 | >>> management.call_command('flush', verbosity=0, interactive=False) |
|---|
| | 93 | |
|---|
| | 94 | # Load fixture 4 (compressed), using format specification |
|---|
| | 95 | >>> management.call_command('loaddata', 'fixture4.json', verbosity=0) |
|---|
| | 96 | >>> Article.objects.all() |
|---|
| | 97 | [<Article: Django pets kitten>, <Article: Python program becomes self aware>] |
|---|
| | 98 | |
|---|
| | 99 | >>> management.call_command('flush', verbosity=0, interactive=False) |
|---|
| | 100 | |
|---|
| | 101 | # Load fixture 5 (compressed), using format *and* compression specification |
|---|
| | 102 | >>> management.call_command('loaddata', 'fixture5.json.zip', verbosity=0) |
|---|
| | 103 | >>> Article.objects.all() |
|---|
| | 104 | [<Article: WoW subscribers now outnumber readers>, <Article: Python program becomes self aware>] |
|---|
| | 105 | |
|---|
| | 106 | >>> management.call_command('flush', verbosity=0, interactive=False) |
|---|
| | 107 | |
|---|
| | 108 | # Load fixture 5 (compressed), only compression specification |
|---|
| | 109 | >>> management.call_command('loaddata', 'fixture5.zip', verbosity=0) |
|---|
| | 110 | >>> Article.objects.all() |
|---|
| | 111 | [<Article: WoW subscribers now outnumber readers>, <Article: Python program becomes self aware>] |
|---|
| | 112 | |
|---|
| | 113 | >>> management.call_command('flush', verbosity=0, interactive=False) |
|---|
| | 114 | |
|---|
| | 115 | # Try to load fixture 5 using format and compression discovery; this will fail |
|---|
| | 116 | # because there are two fixture5's in the fixtures directory |
|---|
| | 117 | >>> management.call_command('loaddata', 'fixture5', verbosity=0) # doctest: +ELLIPSIS |
|---|
| | 118 | Multiple fixtures named 'fixture5' in '...fixtures'. Aborting. |
|---|