Friday, May 27, 2016

Re: with django, how to write a grdview or table to show information and add a button or link in each row for approval?

currently the error is 

dictionary update sequence element #0 has length 5; 2 is required


def post_detail(request):
    posts = []
    with open('/home/martin/Downloads/site1/site1/reg/newusers.csv', 'rb') as csvfile:
     reader = csv.DictReader(csvfile)
     for row in reader:
      if len(row['name'].strip()) > 0 and len(row['project'].strip()) > 0 and len(row['initial password'].strip()) > 0 and len(row['email address'].strip()) > 0 and len(row['company'].strip()) > 0 and len(row['userType'].strip()) > 0 and len(row['businessType'].strip()) > 0 and len(row['contact'].strip()) > 0 and len(row['name'].strip()) > 0:
       eachbracket = {'name' : row['name'].strip(), 'project' : row['project'].strip(), 'businessType' : row['businessType'].strip(), 'userType' : row['userType'].strip(), 'company' : row['company'].strip()}
       posts = posts + [eachbracket]
    #posts = posts1
    print posts
    return render(request, 'approval.html', posts)


On Friday, May 27, 2016 at 3:25:35 PM UTC+8, jorr...@gmail.com wrote:
Sounds like Formsets is what you are looking for.

--
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/c98bec22-e865-45f3-a524-b2aba6d76825%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment