我是Django的初学者,在Python上更先进一点。我对Django感到非常惊讶,而且我已经玩了一段时间了。我查看了很多教程和stackoverflow问题/答案,并发现了很多。
但是,当谈到OneToMany / Foreign Key关系以及访问它的方式时,我仍然有点迷失。我看了一下"图书馆/书"官方文档的例子,但仍试图找出如何解决以下问题。
[说明]
2017-03-28 10:06:01,422 INFO [main-SendThread(192.168.99.101:2181)] zookeeper.ClientCnxn (ClientCnxn.java:primeConnection(852)) - Socket connection established to 192.168.99.101/192.168.99.101:2181, initiating session
2017-03-28 10:06:01,427 INFO [main-SendThread(192.168.99.101:2181)] zookeeper.ClientCnxn (ClientCnxn.java:onConnected(1235)) - Session establishment complete on server 192.168.99.101/192.168.99.101:2181, sessionid = 0x15b1534b9900009, negotiated timeout = 40000
2017-03-28 10:06:50,084 INFO [hconnection-0x4206a205-metaLookup-shared--pool2-t1] client.RpcRetryingCaller (RpcRetryingCaller.java:callWithRetries(142)) - Call exception, tries=10, retries=35, started=48438 ms ago, cancelled=false, msg=row 'user, ,99999999999999' on table 'hbase:meta' at region=hbase:meta,,1.1588230740, hostname=hbasepmx,37628,1490709431477, seqNum=0
2017-03-28 10:07:02,605 INFO [hconnection-0x4206a205-metaLookup-shared--pool2-t1] client.RpcRetryingCaller (RpcRetryingCaller.java:callWithRetries(142)) - Call exception, tries=11, retries=35, started=60963 ms ago, cancelled=true, msg=row 'user, ,99999999999999' on table 'hbase:meta' at region=hbase:meta,,1.1588230740, hostname=hbasepmx,37628,1490709431477, seqNum=0
2017-03-28 10:07:48,168 INFO [hconnection-0x4206a205-metaLookup-shared--pool2-t2] client.RpcRetryingCaller (RpcRetryingCaller.java:callWithRetries(142)) - Call exception, tries=10, retries=35, started=46421 ms ago, cancelled=false, msg=row 'user, ,99999999999999' on table 'hbase:meta' at region=hbase:meta,,1.1588230740, hostname=hbasepmx,37628,1490709431477, seqNum=0
2017-03-
[我正在寻找什么]
我想知道你会怎么做:
答案 0 :(得分:0)
通常,您使用双下划线语法来关注关系。因此,例如,要获得拥有导演头衔的用户,您可以这样做:
User.objects.filter(profile__title__status='Director')
但是,如果您需要机会而不是用户,则需要从商机模型开始。所以:
Opportunity.objects.filter(status__status='alive', director__profile__title__status='Director')
如果您将“商机”指向“个人资料”而非“用户”,则此查询可能会稍微不那么糟糕。