本文整理汇总了Python中models.Photo.owner方法的典型用法代码示例。如果您正苦于以下问题:Python Photo.owner方法的具体用法?Python Photo.owner怎么用?Python Photo.owner使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Photo
的用法示例。
在下文中一共展示了Photo.owner方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: upload_pic
# 需要导入模块: from models import Photo [as 别名]
# 或者: from models.Photo import owner [as 别名]
def upload_pic(request):
if request.method == 'POST':
form = ImageUploadForm(request.POST, request.FILES)
if form.is_valid():
user = request.user
photo = Photo()
photo.photo = form.cleaned_data['image']
photo.public = form.cleaned_data['public']
photo.name = form.cleaned_data['name']
photo.owner = user.customuser
photo.save()
# print(photo.photo)
return HttpResponseRedirect('/photos/success_upload/')
elif request.method == 'GET':
form = ImageUploadForm()
return render(request, 'photos/upload.html', {'form': form})
return render(request, 'photos/upload.html', {'form': form})
示例2: upload
# 需要导入模块: from models import Photo [as 别名]
# 或者: from models.Photo import owner [as 别名]
def upload():
lightbox_id = int(request.form['lightboxId'])
lightbox = Lightbox.get_by_id(lightbox_id)
photos = []
for file in request.files.getlist('file'):
logger.debug('processing file name %s for lightbox id: %d' % (file.filename, lightbox_id))
photo = Photo()
photo.lightbox = lightbox
image_data = file.read()
photo.full_image = db.Blob(image_data)
photo.thumbnail = db.Blob(images.resize(image_data, 180, 180))
photo.owner = users.get_current_user()
photo.name = file.filename
photo.put()
photos.append(photo.key().id())
return jsonify(lightbox={"id": lightbox.key().id(), "photos": photos})
示例3: writeToDB
# 需要导入模块: from models import Photo [as 别名]
# 或者: from models.Photo import owner [as 别名]
def writeToDB(photo, nickname):
newPhoto = Photo()
newPhoto.owner = nickname
newPhoto.photoid = photo.gphoto_id.text
newPhoto.thumbnail = photo.media.thumbnail[2].url
newPhoto.title = photo.title.text
try:
newPhoto.time = datetime.datetime.fromtimestamp(float(photo.exif.time.text) / 1e3)
except:
pass
try:
newPhoto.exposure = photo.exif.exposure.text
except:
pass
try:
newPhoto.focallength = photo.exif.focallength.text
except:
pass
try:
newPhoto.make = photo.exif.make.text
except:
pass
try:
newPhoto.fstop = photo.exif.fstop.text
except:
pass
try:
newPhoto.model = photo.exif.model.text
except:
pass
try:
newPhoto.flash = photo.exif.flash.text
except:
pass
try:
newPhoto.iso = photo.exif.iso.text
except:
pass
# Add to db after retrieved
newPhoto.put()