[Fixed]-'unicode' object has no attribute 'has_header'

1👍

You should change your post method as follows, because you are returning before converting to excel

def post(self, request, *args, **kwargs):
        form_class = self.get_form_class()
        form = self.get_form(form_class)
        if request.user.is_staff:
            if form.is_valid():
                emails = ClientContact.objects.all()
                # Look here
                list_of_emails = []
                for email in emails:
                    email_lst = []
                    email_lst.append(email.user.email)
                    list_of_emails.append(email_lst)
                return excel.make_response_from_array(list_of_emails,
                                                      "xls",
                                                      file_name="export_client_mail",
                                                      status=200)
                else:
                    return HttpResponseBadRequest()
            else:
                return HttpResponseForbidden()
👤latsha

Leave a comment