This is my model class
#!/usr/bin/python
from django.db import models
class olWS(models.Model):
country=models.CharField(max_length=4)
comment=models.TextField()
And this is how i’m trying to put in values recursively in the model fields while iterating over xml data from django shell.
>>> from ol.models import olWS
>>> import xml.etree.cElementTree as ET
>>> tree=ET.ElementTree(file='data1')
>>> ws=olWS()
>>> for el in tree.iter():
... if el.tag=='cusotm_var4':
... ws.country=el.text
... if el.tag=='comments':
... ws.comment=el.text
...
>>> ws.save()
>>> ws.id
1
>>> ws.country
'US'
>>> ws.comment
'where are my cds i ordered'
and what i’m getting is just a single row been fed in the model.
How can I get all the values being iterated over in the xml data, in modelfields.
You need to create and save your instances within the loop; you are only assigning values in the loop in your example.