Search code examples
pythongoogle-app-engineblobstore

store the BlobKey in the model


I am wondering about what the best way of saving a blobstore reference The documented way would be like so:

blobstore.BlobReferenceProperty()

or

ndb.BlobKeyProperty()

or

db.StringProperty()

Are there any disadvantages to save a text string of the key?


Solution

  • blobstore.BlobReferenceProperty That works in my apps and if you need an image class that can hold several images you can use something like

    class Image(db.Model):
    
        reference = db.ReferenceProperty(Article,
                collection_name='matched_images', verbose_name='Title')
        primary_image = blobstore.BlobReferenceProperty()