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 管理员中嵌套内联?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

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

                  相关文档推荐

                  groupby multiple coords along a single dimension in xarray(在xarray中按单个维度的多个坐标分组)
                  Group by and Sum in Pandas without losing columns(Pandas中的GROUP BY AND SUM不丢失列)
                  Group by + New Column + Grab value former row based on conditionals(GROUP BY+新列+基于条件的前一行抓取值)
                  Groupby and interpolate in Pandas(PANDA中的Groupby算法和插值算法)
                  Pandas - Group Rows based on a column and replace NaN with non-null values(PANAS-基于列对行进行分组,并将NaN替换为非空值)
                  Grouping pandas DataFrame by 10 minute intervals(按10分钟间隔对 pandas 数据帧进行分组)

                      <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'>