0

I am very new to Django so not sure how to approach this problem:

I have a large number of models that need to be populated. They have one to many relationships as well as some MPTT relationships. What is the best way to create these? I've seen bulk_create but since it does not create PKs I don't think this will be useful.

I'm thinking about going around the ORM and uploading directly to the database, but I am afraid this will break django. Would this work? (any examples), or perhaps I should be using something like South?

RedRaven
  • 725
  • 2
  • 18
  • 33
  • For the bulk upload you could put the data into a csv and use python manage shell with Django's ORM.. – Michael Burns Feb 27 '14 at 22:33
  • You can write a management command to create the object, and save it to the database. – karthikr Feb 27 '14 at 22:33
  • @MichaelBurns this sounds like what I am looking for, but could you provide an example/explanation/link (like I said, I'm very new to this...) – RedRaven Feb 27 '14 at 23:30
  • 1
    You can use a csv to bulk import to Django ORM: [Similar Question/Answer](http://stackoverflow.com/questions/2459979/how-to-import-csv-data-into-django-models) – Michael Burns Feb 27 '14 at 23:35
  • this and get-or-create was what I was looking for, if you want to make this the answer I will accept it. – RedRaven Feb 28 '14 at 02:04

0 Answers0