Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>One good way to do this is via fixtures, particularly the <code>initial_data</code> fixtures.</p> <p>A fixture is a collection of files that contain the serialized contents of the database. So it's like having a backup of the database but as it's something Django is aware of it's easier to use and will have additional benefits when you come to do things like unit testing.</p> <p>You can create a fixture from the data currently in your DB using <code>django-admin.py dumpdata</code>. By default the data is in JSON format, but other options such as XML are available. A good place to store fixtures is a <code>fixtures</code> sub-directory of your application directories.</p> <p>You can load a fixure using <code>django-admin.py loaddata</code> but more significantly, if your fixture has a name like <code>initial_data.json</code> it will be automatically loaded when you do a <code>syncdb</code>, saving the trouble of importing it yourself.</p> <p>Another benefit is that when you run <code>manage.py test</code> to run your Unit Tests the temporary test database will also have the Initial Data Fixture loaded.</p> <p>Of course, this will work when when you're adding attributes to models and columns to the DB. If you drop a column from the Database you'll need to update your fixture to remove the data for that column which might not be straightforward.</p> <p>This works best when doing lots of little database changes during development. For updating production DBs a manually generated SQL script can often work best.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload