当前位置: 首页>>代码示例>>Python>>正文


Python UploadFileForm.is_multipart方法代码示例

本文整理汇总了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')
开发者ID:youtaya,项目名称:mothertree,代码行数:28,代码来源:views.py

示例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')
开发者ID:youtaya,项目名称:mothertree,代码行数:17,代码来源:views.py


注:本文中的forms.UploadFileForm.is_multipart方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。