Reputation: 1549
I have an XML file.
Is there a way to generate Django models from the XML file? or should I hardcode it?
I've been searching online for hours, and I guess "rest frame work" and "django adaptors" do the job, but I am not so sure how to go about doing that.
If there is anyone familiar with Django and XML, any help will be appreciated.
Thank you.
Upvotes: 1
Views: 1338
Reputation: 6467
Here a talk which contains a tutorial to import an xml file as class:
http://youtu.be/sPiWg5jSoZI?t=2h30s
If you run with py3k, (I think this particular demo of this awesome and funny demonstration is compatible with python 2.6 and upper), you'll get the idea on how to replace your models.py by a models.xml. You'll have to adapt it to your xml format by yourself.
(you'll need to look at least from around 2h to 2h32m)
This talk explain a fun way to do it, the speaker doesn't seem convinced that it's a great idea. If you want to generate api models from WSDL, I would suggest you to still make your tables models in hard code as your database isn't dynamic I suppose. Simply make methods/static methods to translate api models to db models.
Upvotes: 2