Saving a Cloudinary object to a Django Model -


i have model:

from cloudinary.models import cloudinaryfield  class image(models.model):     image = cloudinaryfield('image') 

and object received cloudinary. given me cloudinary after uploaded image, , passed server:

{'etag': ['***'], 'version': ['***'], 'public_id': ['***'], 'type': ['upload'], 'signature': ['***'], 'created_at': ['2017-07-28t15:54:17z'], 'secure_url': ['https://res.cloudinary.com/***/***.png'], 'height': ['353'], 'format': ['png'], 'resource_type': ['image'], 'url': ['http://res.cloudinary.com/***/image/upload/***/***.png'], 'width': ['684'], 'bytes': ['133509']} 

i can't seem save model. have tried both saving directly , putting through cloudinaryjsfilefield form in cloudinary's documentation. neither seems work. form laments "no file selected" , model.create() effort complains of missing property.

this form using:

class photodirectform(modelform):      class meta:         model = image         fields = ['image'] 

i've tried both , without cloudinaryjsfilefield, , same error either way:

<tr><th><label for="id_image">image:</label></th><td><ul class="errorlist"><li>no file selected!</li></ul><input type="file" name="image" required id="id_image" /></td></tr> 

obviously wants file, that's not cloudinary gives me after upload image!

does know how save cloudinary objects django database?

did check photo album sample project?

the flow there -

views.py -

form = photoform(request.post, request.files) ... form.save() 

forms.py -

class photoform(modelform): class meta:     model = photo     fields = '__all__' 

models.py -

class photo(models.model): ## misc django fields create_time = models.datetimefield(auto_now_add=true) title = models.charfield("title (optional)", max_length=200, blank=true)  ## points cloudinary image image = cloudinaryfield('image') 

this should save image both in cloudinary , storage.


Comments

Popular posts from this blog

javascript - Create a stacked percentage column -

Optimising Firebase database by automatically overwriting data -

javascript - Angular UI-Grid customTemplate directive causing rows to load slowly/? -