Django汉字Cookie无法存储的问题

cookie值包含中文是,Django无法执行response.set_cookie,在服务器控制台报错:

AttributeError:'NoneType'object has no attribute 'split'

解决办法:使用Json

import json

defcookieTest2(request):

    response = HttpResponse("OK")

    if 'h1' in request.COOKIES:

        h1 = request.COOKIES['h1']

        response.write('<h1>' +json.loads(h1) + '</h1>')

    response.set_cookie("h1",json.dumps("我是COOKIE"))

    return response

Universal Data Access Components Source Code Copyright 1997-2009, Devart. All Rights Reserved There are two ways to compile and install UniDAC for Windows manually. I. Using IDE Delphi and C++ Builder for Win32 -------------------------------- Run your IDE and walk through folowing steps: 1) Compile DAC run-time package (dacXX.dpk) 2) For Delphi 6,7 or C++ Builder 6 compile DAC GUI related package dacvclXX.dpk 3) Compile DAC design-time package (dcldacXX.dpk) 4) Compile UniDAC run-time package (unidacXX.dpk) 5) For Delphi 6,7 or C++ Builder 6 compile UniDAC GUI related package unidacvclXX.dpk If you are going to create CLX applications compile UniDacClx.pas unit separately. 6) Compile and install UniDAC design-time package (dclunidacXX.dpk) You can find these packages in Source\Delphi5\*.dpk - for Delphi 5 Source\Delphi6\*.dpk - for Delphi 6 Source\Delphi7\*.dpk - for Delphi 7 Source\Delphi9\*.dpk - for Delphi 2005 Source\Delphi10\*.dpk - for Delphi 2006 Source\Delphi11\*.dpk - for Delphi 2007 Source\CBuilder5\*.bpk - for C++ Builder 5 Source\CBuilder6\*.bpk - for C++ Builder 6 To compile UniDAC based application add UniDAC Source directory path to the "Library Path". Delphi for .NET ----------------- Run your IDE and walk through folowing steps: 1) Compile DAC run-time package (Devart.Dac.dpk) 2) Compile DAC design-time package (Devart.Dac.Design.dpk) 3) Compile UniDAC run-time package (Devart.UniDac.dpk) 4) Compile and install UniDAC design-time package (Devart.UniDac.Design.dpk) 5) Specify the path to compiled assembles in "Assembly Search Paths" You can find these packages in Source\Delphi9\*.dpk - for Delphi 2005 Source\Delphi10\*.dpk - for Delphi 2006 To compile UniDAC based application add Devart.Dac and Devart.UniDac to Namespace prefixes, add UniDAC Source directory path to the "Library Path" list. II. Using make-files Delphi and C++ Builder for Win32 -------------------------------- 1) Go to one of the following folders (let's denote this folder %MakePath%): Source\Delphi5 - for Delphi 5 Source\Delphi6 - for Delphi 6 Source\Delphi7 - for Delphi 7 Source\Delphi9 - for Delphi 2005 Source\Delphi10 - for Delphi 2006 Source\Delphi11 - for Delphi 2007 Source\CBuilder5 - for C++ Builder 5 Source\CBuilder6 - for C++ Builder 6 2) Find in the 'Make.bat' line containing set IdeDir="D:\Program Files\Borland\Delphi7 and make sure that correct path to IDE is set (always include forward quote and do not include ending quote) 3) Run 'Make.bat'. Binaries will be copied to %MakePath%\UniDac subfolder 4) Copy %MakePath%\UniDac\*.bpl files to a folder that is included in the PATH environment variable 5) Run IDE and add dclunidacXX.bpl via Component->Install Packages... menu 6) To compile UniDAC based application add UniDAC Source directory path to the "Library Path" list Delphi for .NET ----------------- 1) Go to the following folders (let's denote this folder %MakePath%): Source\Delphi9 - for Delphi 2005 Source\Delphi10 - for Delphi 2006 2) Find in the 'Make.bat' line containing For Delphi 2005: set IdeDir="D:\Program Files\Borland\BDS\3.0 For Delphi 2006: set IdeDir="D:\Program Files\Borland\BDS\4.0 and make sure that correct path to IDE is set (always include forward quote and do not include ending quote) 3) Run 'Make.bat'. Binaries will be copied to %MakePath%\UniDac subfolder 4) Run IDE and add Devart.UniDac.Design.dll via Component->Installed .NET Components->.NET VCL Components->Add... menu. Specify the path to compiled assembles in Component->Assembly Search Paths->Add... menu 6) To compile UniDAC based application add Devart.Dac and Devart.UniDac to Tools->Options->Environment Options->Delphi Options->Library-> Namespace prefixes
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值