• <legend id='yZLZG'><style id='yZLZG'><dir id='yZLZG'><q id='yZLZG'></q></dir></style></legend>

      1. <small id='yZLZG'></small><noframes id='yZLZG'>

          <bdo id='yZLZG'></bdo><ul id='yZLZG'></ul>

      2. <tfoot id='yZLZG'></tfoot>
      3. <i id='yZLZG'><tr id='yZLZG'><dt id='yZLZG'><q id='yZLZG'><span id='yZLZG'><b id='yZLZG'><form id='yZLZG'><ins id='yZLZG'></ins><ul id='yZLZG'></ul><sub id='yZLZG'></sub></form><legend id='yZLZG'></legend><bdo id='yZLZG'><pre id='yZLZG'><center id='yZLZG'></center></pre></bdo></b><th id='yZLZG'></th></span></q></dt></tr></i><div id='yZLZG'><tfoot id='yZLZG'></tfoot><dl id='yZLZG'><fieldset id='yZLZG'></fieldset></dl></div>
      4. 连接与 Django 中查询集中记录的多行相关的字段

        时间:2023-06-06
        <legend id='WwCGf'><style id='WwCGf'><dir id='WwCGf'><q id='WwCGf'></q></dir></style></legend>

            <tbody id='WwCGf'></tbody>

        1. <small id='WwCGf'></small><noframes id='WwCGf'>

            <bdo id='WwCGf'></bdo><ul id='WwCGf'></ul>

                <tfoot id='WwCGf'></tfoot>

                <i id='WwCGf'><tr id='WwCGf'><dt id='WwCGf'><q id='WwCGf'><span id='WwCGf'><b id='WwCGf'><form id='WwCGf'><ins id='WwCGf'></ins><ul id='WwCGf'></ul><sub id='WwCGf'></sub></form><legend id='WwCGf'></legend><bdo id='WwCGf'><pre id='WwCGf'><center id='WwCGf'></center></pre></bdo></b><th id='WwCGf'></th></span></q></dt></tr></i><div id='WwCGf'><tfoot id='WwCGf'></tfoot><dl id='WwCGf'><fieldset id='WwCGf'></fieldset></dl></div>
                • 本文介绍了连接与 Django 中查询集中记录的多行相关的字段的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  限时送ChatGPT账号..

                  我必须用一对多的关系建模,我试图用它来区分我的记录类型.假设第一个模型专用于 Book 信息,第二个模型是一些类型,例如 A、B、C,并且 Type 表与 Book 之间存在间接关系,因此每本书可以是 A、B 或 C 或任何可能的组合类型.我想使用串联(或注释中的任何其他可能的函数来收集字段中的所有类型).

                  I have to models with one to many relation with which I try to distinguish the type of my records. Let's say First model is dedicated to Book information and second model is some types such as A, B , C and there is an indirect relation from the Type table to Book, so each book could be A, B or C or any possible combination of Types. I want to use concatenation (or any other possible function in annotation to gather all the types in a field).

                  Book.objects.all(
                  ).annotate(
                      Types = F('TableRelation__Type__Name')
                  ).annotate(
                      CombinedTypes = Concat('Types')
                  )
                  

                  抛出错误,因为只有一个参数被传递给连接.我正在寻找的结果是一个针对 Book 的任何唯一 id 填充了ABAB"的 CombinedTypes 字段,这表明该记录是AB"(或 A、B 和 C 的任何其他组合).

                  which throws an error since only one argument is passed to be Concatenated. The result I am looking for is a CombinedTypes field filled with "ABAB" for any unique id of Book which shows that that record is an "AB" (or any other combination of A,B and C).

                  我怎样才能做到这一点?

                  How can I achieve this?

                  推荐答案

                  我最终使用了 this 中解释的解决方案@Ahmad 在评论中介绍的帖子中的堆栈溢出答案.

                  I ended up using the solution explained in this Stack-overflow answer in the post introduced by @Ahmad in comments.

                  这篇关于连接与 Django 中查询集中记录的多行相关的字段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:使用引用类休眠@OrderBy 下一篇:具有多个索引的 Doctrine 2

                  相关文章

                  最新文章

                • <i id='3zLmr'><tr id='3zLmr'><dt id='3zLmr'><q id='3zLmr'><span id='3zLmr'><b id='3zLmr'><form id='3zLmr'><ins id='3zLmr'></ins><ul id='3zLmr'></ul><sub id='3zLmr'></sub></form><legend id='3zLmr'></legend><bdo id='3zLmr'><pre id='3zLmr'><center id='3zLmr'></center></pre></bdo></b><th id='3zLmr'></th></span></q></dt></tr></i><div id='3zLmr'><tfoot id='3zLmr'></tfoot><dl id='3zLmr'><fieldset id='3zLmr'></fieldset></dl></div>

                  1. <legend id='3zLmr'><style id='3zLmr'><dir id='3zLmr'><q id='3zLmr'></q></dir></style></legend>
                      <bdo id='3zLmr'></bdo><ul id='3zLmr'></ul>

                    <small id='3zLmr'></small><noframes id='3zLmr'>

                    <tfoot id='3zLmr'></tfoot>