码迷,mamicode.com
首页 > 其他好文 > 详细

Django

时间:2016-09-04 23:52:11      阅读:176      评论:0      收藏:0      [点我收藏+]

标签:

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’)
 
 
 
 
 
 
 

Django

标签:

原文地址:http://www.cnblogs.com/yunpiao111/p/5840594.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!