python-django-数据查询条件

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

查询用户的状态是2或者是4的情况

 

 

 

 

空值和空字符串是不一样的东西!!!

 

 

需要注意的是:

 

 项目setting.py里面的时区采用的是美国的时区,我们不要使用这个时区

使用这个时区的,我们输入的日期会进行转换,最终不一样

将USE_TZ = Flase

 

 指定时间之前,或者之后:

 

 

外键查询

 

Python 3.7.6 (default, Jan  8 2020, 20:23:39) [MSC v.1916 64 bit (AMD64)]
Type 'copyright', 'credits' or 'license' for more information
IPython 7.12.0 -- An enhanced Interactive Python. Type '?' for help.
PyDev console: using IPython 7.12.0
Python 3.7.6 (default, Jan  8 2020, 20:23:39) [MSC v.1916 64 bit (AMD64)] on win32
Django 1.11.29
from weibo.models import WeiboUser as User
user = User.objects.get(pk=3)
user
Out[4]: <WeiboUser: User:zhangsan pk:3,nickname:qq>
from weibo.models import Weibo 
 weibo = Weibo.objects.create(user=user,content='微博内容')

weibo.pk
Out[8]: 1
from weibo.models import Commont
Commont.objects.create(user=user,weibo=weibo,content='zhangsan 评论')
Out[10]: <Commont: Commont object>
Commont.objects.create(user=user,weibo=weibo,content='zhangsan 评论2')
Out[11]: <Commont: Commont object>
quan = User.objects.get(pk=2)
Commont.objects.create(user=quan,weibo=weibo,content='quan评论')
Out[13]: <Commont: Commont object>
Commont.objects.create(user=quan,weibo=weibo,content='quan评论2')
Out[14]: <Commont: Commont object>

 

 

 

posted @ 2020-05-08 13:03  linux——quan  阅读(482)  评论(0编辑  收藏  举报