當前位置: 首頁>>代碼示例>>Python>>正文


Python Photo.to_json方法代碼示例

本文整理匯總了Python中photos.models.Photo.to_json方法的典型用法代碼示例。如果您正苦於以下問題:Python Photo.to_json方法的具體用法?Python Photo.to_json怎麽用?Python Photo.to_json使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在photos.models.Photo的用法示例。


在下文中一共展示了Photo.to_json方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: create

# 需要導入模塊: from photos.models import Photo [as 別名]
# 或者: from photos.models.Photo import to_json [as 別名]
    def create(self, request, raw=False, **kwargs):
        """ Uploads a new photo. """
        title = request.CLEANED.get('title', '')
        description = request.CLEANED.get('description', '')
        if request.CLEANED['url']:
            photo = get_picture_from_url(request.CLEANED['url'])
        elif request.CLEANED['file64']:
            photo = request.CLEANED['photo']
        else:
            if request.CLEANED['file']:
                uploaded_file = request.CLEANED['file']
            format = request.CLEANED['format']
            photo = Photo(user=request.user, title=title, description=description)
            photo.image.save("%s.%s" % (uuid.uuid4(), format), uploaded_file)
            photo.save()
            uploaded_file.close()

        return photo.to_json(request=request, detail=request.CLEANED['detail']) if not raw else photo
開發者ID:gage,項目名稱:proto,代碼行數:20,代碼來源:handlers.py


注:本文中的photos.models.Photo.to_json方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。