Jump to content
Sign in to follow this  
Helio13

Inserir várias imagens no mesmo registo no GridFS

Recommended Posts

Helio13

Oi.

Na minha aplicação Django e mongodb estou a inserir fotos no gridfs do mongo.

Inserir apenas uma foto, num registo, tudo ok.

Agora quando quero inserir mais que uma, não estou a conseguir. Estou a definir como uma lista, mas dá erro.

Estou a tentar assim

class Painting(Document):
artist = StringField()
photo = ListField(FileField())
my_painting = Painting(artist='Steve')
my_painting.photo.append(open('C:/BD.JPG', 'r'))
my_painting.save()
Mas dá-me o seguinte erro: Validationerror('file' object has no attribute 'grid_id': ['photo'])

Alguém sabe o que estou a fazer mal?

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

×
×
  • Create New...

Important Information

By using this site you accept our Terms of Use and Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.