首页 > 其他 > 详细

django

时间:2016-01-06 23:36:09      阅读:261      评论:0      收藏:0      [点我收藏+]

#跨表查用__,跨表取用.
ForeignKey
ManyToMany
models.listname.objects.filter(ForeignKeyList__requestname = ‘‘)
userinfo.objects.filter(usertype__id__gt = 5)
userinfo.objects.filter(usertype__name__contain = ‘A‘)
多对多
u1 = UserInfo.objects.get(id = 1)
g1 = UserGroup.objects.get(id =1)
""g1.user.add(u1)
""u1.usergroup_set.add(g1)


from djang.utils.safestring import mark_safe
session cookie
request.session[key] = value
render_to_response().set_cookie(key:value)
request.cookie.get
request.session.get

跨站请求伪造
html :
{%csrf_token%}
后端:
from django.template.context import RequestContext
context_instance = RequsetContext(request)

自定义中间件:
class OneClass(object):
def process_requset(self,request):#第一个
pass
def process_view(self,request,callback,callback_argv):#第二个
pass
def process_exception(self,request,exception):#第三个
pass
def process_response(self,request,response):#第四个
pass
return response

多个中间件:
class1.process_requset
class2.process_requset
==类似

django admin
models.class.

django

原文:http://www.cnblogs.com/wangyong1027/p/5107699.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!