简体   繁体   English

数据库查询上的空白输出

[英]Blank output on db query

im trying to run this python-django code below, but am getting a blank output 我试图在下面运行此python-django代码,但输出为空

SitePaths = PathsOfDomain.objects.filter(pathToScan__contains="www.myapp.com")

        return SitePaths

PathsOfDomain is the object representation of a db table. PathsOfDomain是数据库表的对象表示形式。

I'm trying to iterate through a db field name pathToScan and output each value 我正在尝试遍历数据库字段名称pathToScan并输出每个值

If someone can please shed some light on this. 如果有人可以请您对此有所说明。

Thank you. 谢谢。

If you meant to query for matching PathsOfDomain rows in the database, use the .objects attribute to create a query set: 如果要查询数据库中匹配的PathsOfDomain行,请使用.objects属性创建查询集:

SitePaths = PathsOfDomain.objects.filter(FKtoTld__id=domain_in_session)

See Making queries in the Django documentation. 进行查询 Django的文档。

Alternatively, if there is a foreign key relationship between the Tld and PathsOfDomain objects, use the related objects manager instead: 或者,如果TldPathsOfDomain对象之间存在外键关系,请改用相关的对象管理器

SitePaths = domain_in_session.pathsofdomain_set.all()

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM