javascript - TypeError: must be string or buffer, not instance -
i using django-jsignature in django project. after making post request, form returns "type 'instance'". i'm trying save image, above error.
even better save form data vector image suggested in docs.
my function:
def signature(request): form = signatureform(request.post or none) if form.is_valid(): signature = form.cleaned_data.get('signature') if signature: # image signature_picture = draw_signature(signature) signature_file_path = draw_signature(signature, as_file=true) open(signature_file_path), 'wb') f: f.write(signature_picture)
(signature_file_path == '/tmp/tmpb71wft.png')
i think docs bit unclear, should using either draw_signature(data, as_file=false)
(default) or draw_signature(data, as_file=true)
, no need both.
passing true
value as_file
makes package dump image content file, while false
makes return pil.image instance.
the raw data still available in signature
variable (as json string or list, use vector directly.
Comments
Post a Comment