how to get url for gridfs

130 views
Skip to first unread message

软刀

unread,
Aug 21, 2012, 5:54:05 PM8/21/12
to mongoeng...@googlegroups.com
i use django1.4 + mongoengine + mongoform
I had add DEFAULT_FILE_STORAGE = 'mongoengine.django.storage.GridFSStorage'  to setting file

I write my models like this

class UserProfile(Document):
    user = ReferenceField(User, unique=True)
    about = StringField()
    photo = ImageField(thumbnail_size=(256,256))

and I had success upload Image file to mongodb
> db.user_profile.find()
{ "_cls" : "UserProfile", "_id" : ObjectId("5032a8e1d9747e1bb3d535bb"), "_types" : [ "UserProfile" ], "about" : "l;kjlk", "photo" : ObjectId("5033faefd9747e7672a17add"), "user" : { "$ref" : "user", "$id" : ObjectId("503142c4d9747e54b358621a") } }

I try to use {{ document.photo.url }} {{ document.photo.get_absolute_url }}  but failed

how to get the ImageField's url and it's thumbnail's url?

thank you

Samir Hinojosa

unread,
May 20, 2014, 12:26:46 AM5/20/14
to mongoeng...@googlegroups.com
Hi, 

could you solve this problem?
Reply all
Reply to author
Forward
0 new messages