摘要:
CSRF verification failed. Request aborted.默认会出现该状况,解决办法:1.使用requestcontextfrom django.template import RequestContext……return render_to_response('my_template.html',my_data_dictionary,context_instance=RequestContext(request))2.在表单中添加tag{% csrf_token %}3.setting.py中MIDDLEWARE_CLASSES加入'djan 阅读全文
随笔档案-2013年10月
python urllib2 Basic认证
2013-10-11 18:06 by cmsd, 1916 阅读, 收藏, 编辑
摘要:
1.通过添加http header 来实现import urllib2from base64 import encodestringurl = 'http://202.108.1.51'user = 'a'passwd = 'aa' req = urllib2.Request(url)basestr = encodestring('%s:%s' % (user,passwd))[:-1]req.add_header('Authorization','Basic %s' % basestr)f = u 阅读全文