Error with Django and Cloudinary - can not use the string pattern on a bytes-like object

0

I'm trying to make a simple app: I've done the Django Girls tutorial and now I'm trying to use it as well including an image using the < a href="http://cloudinary.com/"> Cloudinary

But I'm having the following error:

Theerroroccursatlineupload_result=cloudinary.uploader.upload(file)offileviews.py

Followcode

models.py

fromdjango.dbimportmodelsfromdjango.utilsimporttimezonefromcloudinary.modelsimportCloudinaryFieldclassPost(models.Model):author=models.ForeignKey('auth.User')title=models.CharField(max_length=200)text=models.TextField()create_date=models.DateTimeField(default=timezone.now)published_date=models.DateTimeField(blank=True,null=True)image_url=CloudinaryField('imagem',blank=True,null=True)defpublish(sefl):self.published_date=timezone.now()self.save()def__str__(self):returnself.title

views.py

defpost_new(request):upload_result=Nonethumbnail=Noneifrequest.method=="POST":
        form = PostForm(request.POST, request.FILES)
        if form.is_valid():
            file = request.FILES['image_url']
            if file:
                upload_result = cloudinary.uploader.upload(file)
                thumbnail, option = cloudinary_url(upload_result['public_id'], format="jpg", crop="fill", width=100, height=100)

            post = form.save(commit=False)
            post.author = request.user
            post.published_date = timezone.now()
            post.save()
            return redirect('post_detail', pk=post.pk)
    else:
        form = PostForm()
    return render(request, 'blog/post_edit.html', {'form': form})

post_edit.html

{% extends 'blog/base.html' %}

{% load cloudinary %}

{% block content %}
    <h1>Nova postagem</h1>

    <form action="" method="post" class="post-form" enctype="multipart/form-data">
        {% csrf_token %}

        {{ form.as_table }}

        <br />
        <div class="col-md-3">
            <input type="submit" value="Salvar" class="btn btn-success">
        </div>
    </form>
{% endblock %}

If anyone can, include the cloudinary tag.

    
asked by anonymous 03.02.2016 / 20:22

1 answer

2

I was having this same problem, it turned out that the library was incompatible with some new Python 3.x functions and fixed them in version 1.3.1

Upgrades version of Cloudinary package to 1.3.1

    
04.02.2016 / 10:44