You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
edit: The fix for this is to install directly from the git repository, PyPI release is not the latest code on master. Leaving the below for @tBaxter reference.
Good Day TBaxter,
Thank you for a the project. I had been using it fine with python2, but a migration to python3 is tripping me up and I'm not sure how to fix it. I hope you can help.
This is how I'm creating the card (it works fine):
defvcard(self):
the_card=card_me.vCard()
the_card.add("n")
the_card.n.value=card_me.vcard.Name(given=self.user.name)
the_card.add("fn")
the_card.fn.value=u"%s"% (self.user.name)
the_card.add("email")
the_card.email.value=self.user.emailthe_card.email.type_param="WORK"the_card.add("tel")
the_card.tel.value="%s"%self.mobile_numberthe_card.tel.type_param="WORK"the_card.add("adr")
the_card.adr.value=card_me.vcard.Address(country=(self.country.name,))
the_card.adr.type_parm="HOME"the_card.add("photo")
buf=BytesIO()
img=Image.open(self.image.file)
img.thumbnail((600, 600), Image.ANTIALIAS)
img.save(buf, img.format)
the_card.photo.value=buf.getvalue()
the_card.photo.encoding_param="b"the_card.photo.type_param=img.formatifself.company_name:
the_card.add("org")
# we need to do this like this because of the way this is serialisedthe_card.org.value= (self.company_name,)
ifself.website:
the_card.add("url")
the_card.url.value=self.websitereturnthe_card
However, when trying to serialize as so the problem occurs:
@login_requireddefcreate_vcard(request, username):
user=get_object_or_404(User, username=username, is_staff=False)
response=HttpResponse(
user.profile.vcard().serialize(), content_type="text/vcard"# problem occurs here
)
filename="contact.vcf"response["Filename"] =filenameresponse["Content-Disposition"] ="attachment; filename=%s"%filenamereturnresponse
Thanks again for the project. Apologies if this is the wrong place to ask this.
The text was updated successfully, but these errors were encountered:
nsomaru
changed the title
Serializing: 'bytes' object has no attribute 'encode'
New PyPI Release
Jan 27, 2020
edit: The fix for this is to install directly from the git repository, PyPI release is not the latest code on master. Leaving the below for @tBaxter reference.
Good Day TBaxter,
Thank you for a the project. I had been using it fine with python2, but a migration to python3 is tripping me up and I'm not sure how to fix it. I hope you can help.
The exception:
This is how I'm creating the card (it works fine):
However, when trying to serialize as so the problem occurs:
Thanks again for the project. Apologies if this is the wrong place to ask this.
The text was updated successfully, but these errors were encountered: