Created
October 13, 2010 09:10
-
-
Save rozza/623725 to your computer and use it in GitHub Desktop.
An example of using fixtures in south migrations
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.core import serializers | |
widgets = serializers.deserialize('json', open('widget/fixtures/widgets.json')) | |
for widget_data in widgets: | |
widget = orm.Widget() | |
for k,v in widget_data.object.__dict__.items(): | |
if k.startswith('_'): | |
continue | |
setattr(widget, k, v) | |
widget.save() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment