本文整理汇总了Python中models.Image.artist方法的典型用法代码示例。如果您正苦于以下问题:Python Image.artist方法的具体用法?Python Image.artist怎么用?Python Image.artist使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Image
的用法示例。
在下文中一共展示了Image.artist方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: handleImagePopAdd
# 需要导入模块: from models import Image [as 别名]
# 或者: from models.Image import artist [as 别名]
def handleImagePopAdd(request, addForm, field, template="form/popmediaadd.html"):
if not request.method == "POST":
f = UploadForm()
ctx = {'form': f, 'field': field}
return render(request, template, ctx)
f = UploadForm(request.POST, request.FILES)
if not f.is_valid() and not request.FILES['file'].name.endswith('.svg'):
ctx = {'form': f, 'field': field}
return render(request, template, ctx)
file = request.FILES['file']
store_in_s3(file.name, file.read())
p = Image(url="http://%s.s3.amazonaws.com/%s" % (bucket, file.name))
if isinstance(request.user, AnonymousUser):
p.user = User.objects.get(username="Anonymous")
else:
p.user = User.objects.get(username=request.user)
if request.POST['artist']:
p.artist = User.objects.get(pk=request.POST['artist'])
p.save()
newObject = p
# Self destruction:
if newObject:
return HttpResponse('<script type="text/javascript">opener.dismissAddAnotherPopup(window, "%s", "%s");</script>' %\
(escape(newObject._get_pk_val()), escape(newObject)))
示例2: index
# 需要导入模块: from models import Image [as 别名]
# 或者: from models.Image import artist [as 别名]
def index(request, template='./gallery/index.html'):
entry = get("Gallery")
if 'gallery' in request.POST and request.POST['gallery']:
artist = User.objects.get(pk=request.POST['gallery'])
photos = Image.objects.filter(artist=artist).order_by('-uploaded')
else:
photos = Image.objects.all().order_by('-uploaded')
if not request.method == "POST" or ('gallery' in request.POST):
f = UploadForm()
af = ArtistForm(request.POST)
ctx = {'entry': entry, 'form': f, 'photos': photos, 'artist': af}
return render(request, template, ctx)
f = UploadForm(request.POST, request.FILES)
af = ArtistForm(request.POST)
if not f.is_valid() and not request.FILES['file'].name.endswith('.svg'):
ctx = {'entry': entry, 'form': f, 'photos': photos, 'artist': af}
return render(request, template, ctx)
file = request.FILES['file']
#print type(file)
#print dir(file)
#for k,v in file.items(): print k, v
#filename = file._get_name() #['filename']
#content = file['content']
store_in_s3(file.name, file.read())
p = Image(url="http://%s.s3.amazonaws.com/%s" % (bucket, file.name))
if isinstance(request.user, AnonymousUser):
p.user = User.objects.get(username="Anonymous")
else:
p.user = User.objects.get(username=request.user)
if request.POST['artist']:
p.artist = User.objects.get(pk=request.POST['artist'])
p.save()
photos = Image.objects.all().order_by('-uploaded')
ctx = {'entry': entry, 'form': f, 'photos': photos, 'artist': af}
return render(request, template, ctx)