标签:
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’)
标签:
原文地址:http://www.cnblogs.com/yunpiao111/p/5840594.html