本文整理汇总了Python中forms.UploadFileForm.is_multipart方法的典型用法代码示例。如果您正苦于以下问题:Python UploadFileForm.is_multipart方法的具体用法?Python UploadFileForm.is_multipart怎么用?Python UploadFileForm.is_multipart使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类forms.UploadFileForm
的用法示例。
在下文中一共展示了UploadFileForm.is_multipart方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: add_avatar
# 需要导入模块: from forms import UploadFileForm [as 别名]
# 或者: from forms.UploadFileForm import is_multipart [as 别名]
def add_avatar(request):
#get image from client
#save image to media folder
if request.method == "POST":
logger.debug("[photo]request POST form: "+ str(request.POST))
form = UploadFileForm(request.POST, request.FILES)
logger.debug("[photo]request FILES form: "+ str(request.FILES))
user_name = request.POST.get('username')
logger.debug("user name: "+user_name)
if form.is_valid() and form.is_multipart():
logger.debug("[photo]upload image: "+str(request.FILES))
save_file(request.FILES['image'])
# save image path to avatar url
client_user = User.objects.get(username = user_name)
client_info = UserInfo.objects.get(user=client_user)
client_info.avatar.save(request.FILES['image'].name, request.FILES['image'])
client_info.save()
return HttpResponse(200)
else:
return HttpResponse('invalid image')
if request.method == "GET":
return render(request, 'times/photo.html')
示例2: photo
# 需要导入模块: from forms import UploadFileForm [as 别名]
# 或者: from forms.UploadFileForm import is_multipart [as 别名]
def photo(request):
#get image from client
#save image to media folder
if request.method == "POST":
form = UploadFileForm(request.POST, request.FILES)
logger.debug("[photo]request POST form: "+ str(request.POST))
if form.is_valid() and form.is_multipart():
logger.debug("[photo]upload image: "+str(request.FILES))
save_file(request.FILES['image'])
return HttpResponse(200)
else:
return HttpResponse('invalid image')
if request.method == "GET":
return render(request, 'times/photo.html')