Reputation: 389
I'm having some issues integrating Cloudinary into Django.
I have a form on my site, that excepts URLs. This URL is then being parsed with BS4 to find an image URL:
def add(request):
...
product.image_url = soup.find('meta', property='image')["content"]
...
I then pass URL to cloudinary.uploader:
...
product.image = cloudinary.uploader.upload(product.image_url)
product.save()
return redirect(product.get_absolute_url())
I've added the CloudinaryField to the product's class:
class Product(models.Model):
image = CloudinaryField('image')
When I'm trying to add the product, I'm getting the following error: ProgrammingError at /product/add
can't adapt type 'dict'
Would appreciate your help with this one.
Upvotes: 1
Views: 692
Reputation: 389
Solved it by adding this:
product.image = cloudinary.uploader.upload(product.image_url)['public_id']
Upvotes: 1