python-django-数据查询条件

 

 python-django-数据查询条件

 

 python-django-数据查询条件

 

 python-django-数据查询条件

 

 python-django-数据查询条件

 

 python-django-数据查询条件

 

 python-django-数据查询条件

 

 python-django-数据查询条件

 

 

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

python-django-数据查询条件

 

 

python-django-数据查询条件

 

 

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

python-django-数据查询条件

 

 

需要注意的是:

python-django-数据查询条件

 

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

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

将USE_TZ = Flase

python-django-数据查询条件

 

 python-django-数据查询条件指定时间之前,或者之后:

python-django-数据查询条件

 

 

外键查询

 

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>

python-django-数据查询条件

 

 python-django-数据查询条件

 

相关文章:

  • 2021-08-28
  • 2022-12-23
  • 2022-12-23
  • 2021-11-23
  • 2022-12-23
  • 2022-02-18
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-06-18
  • 2021-10-12
  • 2022-12-23
  • 2021-08-06
  • 2021-08-08
相关资源
相似解决方案