django fixtures

Showing 1-2 of 2 messages
django fixtures CrabbyPete 3/8/11 7:13 PM
I know I can do it manually but is there a way to use fixtures to
preload the database. I used the mongoimport, but was wondering if
fixtures can be integrated into MongoEngine with django
Re: django fixtures Ankhbayar Lhagvadorj 3/9/11 2:15 AM
Try this.

datas = []
for u in User.objects.all():
json.dumps(datas, sort_keys=True, indent=4, default=json_util.default) # Write to file. 

# Load FROM json
from mongoengine import base as mongobase
f = open("./dump.json", 'r') # JSON file
datas = json.loads(, object_hook=json_util.object_hook )
for data in datas:
  model = mongobase._document_registry.has_key(data['_cls']) # Check in newer verions !!!
  model_instance = model._from_son(data) = False) # Ingore Ref fields
Хүндэтгэсэн Анхбаяр