1. <tfoot id='1UWQz'></tfoot>

      <small id='1UWQz'></small><noframes id='1UWQz'>

        <bdo id='1UWQz'></bdo><ul id='1UWQz'></ul>

      <legend id='1UWQz'><style id='1UWQz'><dir id='1UWQz'><q id='1UWQz'></q></dir></style></legend>

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

        在 Django 管理员中嵌套内联?

        Nested inlines in the Django admin?(在 Django 管理员中嵌套内联?)

        <small id='jBaIr'></small><noframes id='jBaIr'>

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

            • <bdo id='jBaIr'></bdo><ul id='jBaIr'></ul>

                  <tbody id='jBaIr'></tbody>

                  本文介绍了在 Django 管理员中嵌套内联?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  好的,我有一个相当简单的设计.

                  Alright, I have a fairly simple design.

                  class Update(models.Model):
                      pub_date = models.DateField()
                      title = models.CharField(max_length=512)
                  
                  class Post(models.Model):
                      update = models.ForeignKey(Update)
                      body = models.TextField()
                      order = models.PositiveIntegerField(blank=True)
                  
                  class Media(models.Model):
                      post = models.ForeignKey(Post)
                      thumb = models.ImageField(upload_to='frontpage')
                      fullImagePath = models.ImageField(upload_to='frontpage')
                  

                  有没有一种简单的方法可以让用户在一个页面上创建更新?

                  Is there an easy-ish way to allow a user to create an update all on one page?

                  想要是让用户能够进入管理界面,添加新的更新,然后在编辑更新时添加一个或多个帖子,每个帖子都有一个或更多媒体项目.此外,我希望用户能够在更新中重新排序帖子.

                  What I want is for a user to be able to go to the admin interface, add a new Update, and then while editing an Update add one or more Posts, with each Post having one or more Media items. In addition, I want the user to be able to reorder Posts within an update.

                  我当前的尝试在 admin.py 中有以下内容:

                  My current attempt has the following in admin.py:

                  class MediaInline(admin.StackedInline):
                      model = Media
                  
                  class PostAdmin(admin.ModelAdmin):
                      inlines = [MediaInline,]
                  

                  这让用户添加一个新的帖子项目,选择相关的更新,将媒体项目添加到其中,然后点击保存 - 这很好.但是没有办法在一个地方查看属于给定更新的所有帖子,这反过来意味着您不能在更新中使用帖子.对于最终用户来说,这真的很令人困惑.

                  This let's the user add a new Post item, select the relevant Update, add the Media items to it, and hit save - which is fine. But there's no way to see all the Posts that belong to a given Update in a single place, which in turn means you can't roderder Posts within an update. It's really quite confusing for the end user.

                  帮助?

                  推荐答案

                  截至目前,在 django.contrib.admin 中没有内置"方式来嵌套内联(inline inside inline).通过拥有自己的 ModelAdmin 和 InlineModelAdmin 子类来启用这种功能,可以实现这样的功能.查看这张票上的补丁 http://code.djangoproject.com/ticket/9025 以获得想法关于如何实现这一点.您还需要提供自己的模板,这些模板将在顶级内联和子内联上进行嵌套迭代.

                  As of now there is no "built-in" way to have nested inlines (inline inside inline) in django.contrib.admin. Pulling something like this off is possible by having your own ModelAdmin and InlineModelAdmin subclasses that would enable this kind of functionality. See the patches on this ticket http://code.djangoproject.com/ticket/9025 for ideas on how to implement this. You'd also need to provide your own templates that would have nested iteration over both the top level inline and it's child inline.

                  这篇关于在 Django 管理员中嵌套内联?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  What happens when you compare 2 pandas Series(当你比较 2 个 pandas 系列时会发生什么)
                  Quickly find differences between two large text files(快速查找两个大文本文件之间的差异)
                  Python - Compare 2 files and output differences(Python - 比较 2 个文件和输出差异)
                  Why do comparisions between very large float values fail in python?(为什么在 python 中非常大的浮点值之间的比较会失败?)
                  Dictionary merge by updating but not overwriting if value exists(字典通过更新合并,但如果值存在则不覆盖)
                  Find entries of one text file in another file in python(在python中的另一个文件中查找一个文本文件的条目)

                      <legend id='JU98D'><style id='JU98D'><dir id='JU98D'><q id='JU98D'></q></dir></style></legend>

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

                          • <tfoot id='JU98D'></tfoot>
                              <tbody id='JU98D'></tbody>

                            <small id='JU98D'></small><noframes id='JU98D'>