skarim / vobject

A full-featured Python package for parsing and creating iCalendar and vCard files
https://vobject.sameenkarim.com
255 stars 93 forks source link

'str' object has no attribute 'box' #176

Open ksenthilkumarnissi opened 2 years ago

ksenthilkumarnissi commented 2 years ago

"\"In transformFromNative, unhandled exception on line None <class 'AttributeError'>: 'str' object has no attribute 'box'\""}

Code:

def getVCard(request, id):

            card = vobject.vCard()

            attr = card.add('N')
            attr.value = vobject.vcard.Name(family='', given=serializer_class.data['profile_full_name'])

            attr = card.add('FN')
            attr.value = serializer_class.data['profile_full_name']

            attr = card.add('NICKNAME')
            attr.value = serializer_class.data['profile_full_name']

            attr = card.add('EMAIL')
            attr.value = attr.value = serializer_class.data['profile_email'] 

            attr = card.add('TEL')
            attr.type_param = 'cell'
            attr.value = serializer_class.data['profile_mobile_number']

            attr = card.add('SOURCE')
            attr.type_param = get_current_site(request).domain + '/vcard/' + id

            attr = card.add('ROLE')
            attr.value = serializer_class.data['profile_designation']

            attr = card.add('REV')
            attr.value = datetime.now

            attr = card.add('ORG')
            attr.value =  serializer_class.data['profile_company_name']

            photo_url = settings.AWS_S3_CUSTOM_DOMAIN + serializer_class.data['profile_picture']

            attr = card.add('PHOTO')
            attr.value_param = "URI"
            attr.type_param = 'jpg'
            attr.value = photo_url

            attr = card.add('LOGO')
            attr.type_param = "jpg"
            attr.value = photo_url

            attr = card.add('KIND')
            attr.value = "individual"

            attr = card.add('GENDER')
            attr.value = "M"

            attr = card.add('CATEGORIES')
            attr.value = ("swimmer","biker","business")

            attr = card.add('URL')
            attr.value = serializer_class.data['profile_website']

            attr = card.add('TITLE')
            attr.value = serializer_class.data['profile_profession']

            attr = card.add('CLASS')
            attr.value = "public"

            attr = card.add('NOTE')
            attr.value = "I am the Member"

            attr = card.add('TZ')
            attr.value = timezone.get_current_timezone

            attr = card.add('ADR')
            attr.type_param = "work"
            attr.value = serializer_class.data['profile_company_address']

            response = HttpResponse(content_type='text/x-vcard')
            response['Content-Disposition'] = 'attachment; filename=" %s.vcf"' % serializer_class.data['profile_full_name']
            response.write(card.serialize())
            return response