Django

django 类

django.utils

django.utils.timezone

 

 

 
python 内置
datetime.timedelta(days=1)
 
 
例子 timezone.now()-datetime.timedelte(days=1)
 
django orm 模型
 
Question.objects.filter(id=1)
Question.objects.filter(question_text__startswith='What')
Question.objects.get(id=1)//publish__year=timezone.now().year
 
外键 操作
q = Questions.objects.get(id=1)
q.choice_set.all()
q.choice_set.create(choice_text=’1’,count=1)
q.choice_set.create(choice_text=’2’,count=1)
q.choice_set.create(choice_text=’3’,count=1)
q.save()
q.choice_set.all().count
q.choice_set.filter(chioce_text__starts__with=’1’)
 
 
 
 
 
 
 
posted @ 2016-09-04 22:37  云飘  阅读(200)  评论(0编辑  收藏  举报