read CSV file and save the data in the database, I still don't
understand why you use the forms machinery.
You only *need* to use the data model, e.g.
from myapp.models import Data
csvfile = csv.reader('something.csv')
for line in csvfile:
do_necessary_data_conversions_or_checks(line)
try:
Data.objects.create(field1=line[0], field2=line[1], ...)
except (IndexError, IntegrityError):
print 'Invalid line encountered:\n%s' % line
What am I missing?
Jirka
--
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
No comments:
Post a Comment