【发布时间】:2015-12-09 14:10:09
【问题描述】:
我的项目在我的本地主机中正常运行,但项目在服务器中出现 ascii 代码错误。
Django output:
'ascii' codec can't encode character u'\u0130' in position 78: ordinal not in range(128)
这个我的视图;
def gallery(request):
if admin_permission(request):
return HttpResponseRedirect("/")
showcase_list = Gallery.objects.all()
if request.method == 'POST':
user = User.objects.get(id=request.user.id)
product_code = request.POST.get('product_code')
photo = request.FILES.get('photo')
small_photo = request.FILES.get('small_photo')
# photo.name = 'photo'
# small_photo.name = 'small_photo'
code = request.POST.get('code')
product = Products.objects.get(product_code=product_code)
gallery = Gallery.objects.create(user=user, code=code, product=product, photo=photo, small_photo=small_photo,
is_active=True)
gallery.save()
return render_to_response('Product/showcase/gallery.html', locals(), context_instance=RequestContext(request))
错误页面:
这是文件上传错误。如果文件名包含土耳其字符,则给出该错误。请。帮帮我……
【问题讨论】:
-
一些代码会很有用。目前这个问题没有提供任何细节来调试它。导致异常的完整回溯和代码将非常有用。
-
以文本形式发布回溯(点击“切换到复制粘贴视图”)。
标签: python django file ubuntu server