I'm basically trying to get employees of a manger using ldap. The error I get is TypeError at /aboutus-test/ cannot concatenate 'str' and 'list' objects. I think the issue is it's taking the list of employees and trying to put them all into a function rather than one by one. But I am not sure how to solve the issue, hence being here.
python: 2.7 django: 1.8 sample of my ldap script: def getFTEs(manager): conn = ldap.initialize("ldap://ourldapserver:389/") results = conn.search_s("o=domain.com", ldap.SCOPE_SUBTREE, "uid=" + manager, attrlist=['employeetype']) if len(results) >= 1: Info = results[0][1] directsInfo = str(Info) directs = re.findall('\((.*?)\)', directsInfo) if directs != []: E = [] for direct in directs: conn = ldap.initialize("ldap://ourldapserver:389/") results = conn.search_s("o=domain.com", ldap.SCOPE_SUBTREE, "uid=" + direct, attrlist=['employeetype']) directsinfo = results[0][1] code = directsinfo['employeetype'][0] if code == "F": E.append(direct) return E else: return 'no directs' ftes = getFTEs(manager) def names(ftes): conn = ldap.initialize("ldap://ourldapserver:389/") results = conn.search_s("o=domain.com", ldap.SCOPE_SUBTREE, "uid=" + ftes, attrlist=['gecos']) name2 = results[0][1] gecos = name2['gecos'][0] return gecos I have one of these for all the fields I want. views.py: def aboutus(request): u = request.user.get_username() username = u.split("@")[0] ftes = getFTEs("managername") name = names(ftes) title = titles(ftes) bldg = buildings(ftes) email = emails(ftes) context = RequestContext(request, { 'username': username, 'ftes': ftes, 'name': name, 'title': title, 'bldg': bldg, 'email': email }) return render(request, 'about-test.html', context) in the template: {% for item in ftes %} {{ item.name }}, {{ item.title }}, {{ item.bldg }}, {{ item.email }}<br> {% endfor %} -- 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+unsubscr...@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/d73139a3-77c8-4967-b230-796a86a6260a%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.