django-->views.py
def index(res): ret : {'data':None,'group':None} usergroup = models.UserGroup.objects.all() ret['group'] = usergroup if res.method == 'POST': hostname = res.POST.get('hostname',None) ip = res.POST.get('m_ip','8.8.8.88') user_group = res.POST.get('usergroup',None) models.Asset.objects.create(hostname=hostname,ip=ip,user_group_id=user_group) # return render_to_response('boycott/index.html',{}) #CSRF verification failed. Request aborted. 这个语法是老的,可能会出现左边这个报错 data = models.Asset.objects.all() print(data.query) ret['data'] = data return render(res,'boycott/index.html',ret) #CSRF verification failed. Request aborted.
其他配置都没问题,执行的时候提示
django: local variable ret referenced before assignment,百思不得其解,于是乎把全局变量什么的看了一个下午,最后发现 自己把 =号写成了:冒号,我去............
以后还是带着脑子呼吸吧