Wednesday, April 24, 2013

Re: Upload csv file

1. In your views.index function you have written something like this

       file = request.FILES
     for line in file:

    You cant use file object directly instead try some thing like this 

        file = request.FILES['file']
    for line in file.readlines():
      line = line.split(';')

2. You cant directly access model fields you need to access them with model object.
        
        Nome  = line[0] # wrong

        report.Nome  = line[0] # Correct
    report.Sobrenome = line[1]


Cheers.
Abhijeet Shete

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

No comments:

Post a Comment