djangosnippets.org: Latest snippets tagged with 'loaddata'http://djangosnippets.org/tags/loaddata/2016-09-08T09:09:16.423595-05:00utf8-friendly dumpdata management command for yaml (no escape symbols) #2
2016-09-08T09:09:16.423595-05:00muciushttp://djangosnippets.org/snippets/10586/<p>This is a revised version of https://djangosnippets.org/snippets/2921/</p>
Freely redistributableLoading initial data per model at table creation (useful with migrations)
2014-07-12T05:03:42.184915-05:00GigiusBhttp://djangosnippets.org/snippets/3083/<p>A very simple way of automatically loading data on model creation.</p>
<p>As I am using South I wanted an automatic way of loading initial data only when a new model is create during a migration.
Django provides almost everything out of the box by providing the <em>post_syncdb</em> signal (triggered also …</p>
Freely redistributableMongoDB data load
2013-01-03T09:37:14.144420-06:00jose_lpahttp://djangosnippets.org/snippets/2873/<p>This snippet loads data from JSON files into a MongoDB database.</p>
<p>The code is related with the other snippet <a href="http://djangosnippets.org/snippets/2872/">MongoDB data dump</a>.</p>
<p>To get it working, just create a <code>MONGODB_NAME</code> variable in settings, holding the name of your Mongo database. This can be edited to fit more your needs. …</p>
Freely redistributableRemove old fields on dumpdata generated json
2011-10-21T15:46:38.312378-05:00facundo_olanohttp://djangosnippets.org/snippets/2576/<p>A small script that takes a manage.py dumpdata generated json file, and removes fields of the specified models. I needed this because i kept my initial data on a json file and after I removed a field on one of my models, the script wouldn't work anymore.</p>
Freely redistributableCSV to JSON Fixture
2009-08-11T14:48:45.548683-05:00briangershonhttp://djangosnippets.org/snippets/1680/<p><strong>This script converts a CSV file into a JSON file ready to be imported via <code>manage.py loaddata</code> like any other fixture data.</strong></p>
<p>It can be used manually to do a one-time conversion (for placing into a /fixtures folder), or used in a fabric script that automatically converts CSV to JSON …</p>
Freely redistributabledumpdata/loaddata with MySQL and ForeignKeys
2008-01-02T09:20:40.417055-06:00cmgreenhttp://djangosnippets.org/snippets/533/<p>InnoDB tables within MySQL have no ability to defer reference checking until after a transaction is complete. This prevents most dumpdata/loaddata cycles unless the dump order falls so that referenced models are dumped before models that depend on them.</p>
<p>This code uses <a href="http://www.bitformation.com">Ofer Faigon's</a> topological sort to sort the models …</p>
Freely redistributableExport models as json
2007-03-22T17:06:18.049808-05:00aconberehttp://djangosnippets.org/snippets/125/<p>I use this script to export a group of models that I want to import later as initial data. It exports them as serialized json, which is perfect for importing later with the loaddata function in manage.py.</p>
Freely redistributable