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

      <tfoot id='18nnX'></tfoot>

        <small id='18nnX'></small><noframes id='18nnX'>

        这不是元组吗?

        Is this not a tuple?(这不是元组吗?)

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

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

                • <bdo id='hlz8f'></bdo><ul id='hlz8f'></ul>
                  <legend id='hlz8f'><style id='hlz8f'><dir id='hlz8f'><q id='hlz8f'></q></dir></style></legend>

                  本文介绍了这不是元组吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我无法弄清楚我在这里做错了什么.我的错误是:/admin/'CategoryAdmin.fields' 的配置不当必须是列表或元组.

                  I can't figure out what I'm doing wrong here. My error is: ImproperlyConfigured at /admin/ 'CategoryAdmin.fields' must be a list or tuple.

                  CategoryAdmin.fields 不是元组吗?我读错了吗?

                  Isn't the CategoryAdmin.fields a tuple? Am I reading this wrong?

                  admin.py..

                  class CategoryAdmin(admin.ModelAdmin):
                      fields = ('title')
                      list_display = ('id', 'title', 'creation_date')
                  
                  class PostAdmin(admin.ModelAdmin):
                      fields = ('author', 'title', 'content')
                      list_display = ('id', 'title', 'creation_date')
                  
                  admin.site.register(
                      models.Category, 
                      CategoryAdmin
                  )
                  admin.site.register(
                      models.Post, 
                      PostAdmin
                  )
                  

                  推荐答案

                  不,不是.您需要添加一个逗号:

                  No, it is not. You need to add a comma:

                  fields = ('title',)
                  

                  正是 逗号 使它成为一个元组.括号在这里实际上只是可选的:

                  It is the comma that makes this a tuple. The parenthesis are really just optional here:

                  >>> ('title')
                  'title'
                  >>> 'title',
                  ('title',)
                  

                  括号当然仍然是个好主意,带括号的元组更容易在视觉上发现,并且括号将函数调用中的元组与其他参数(foo(('title',), 'bar')foo('title', 'bar')) 不同.

                  The parenthesis are of course still a good idea, with parenthesis tuples are easier to spot visually, and the parenthesis distinguish the tuple in a function call from other parameters (foo(('title',), 'bar') is different from foo('title', 'bar')).

                  这篇关于这不是元组吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

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

                  相关文档推荐

                  Initialize Multiple Numpy Arrays (Multiple Assignment) - Like MATLAB deal()(初始化多个 Numpy 数组(多重赋值) - 像 MATLAB deal())
                  How to extend Python class init(如何扩展 Python 类初始化)
                  What#39;s the difference between dict() and {}?(dict() 和 {} 有什么区别?)
                  What is a wrapper_descriptor, and why is Foo.__init__() one in this case?(什么是 wrapper_descriptor,为什么 Foo.__init__() 在这种情况下是其中之一?)
                  Initialize list with same bool value(使用相同的布尔值初始化列表)
                  setattr with kwargs, pythonic or not?(setattr 与 kwargs,pythonic 与否?)
                  <i id='DpZBg'><tr id='DpZBg'><dt id='DpZBg'><q id='DpZBg'><span id='DpZBg'><b id='DpZBg'><form id='DpZBg'><ins id='DpZBg'></ins><ul id='DpZBg'></ul><sub id='DpZBg'></sub></form><legend id='DpZBg'></legend><bdo id='DpZBg'><pre id='DpZBg'><center id='DpZBg'></center></pre></bdo></b><th id='DpZBg'></th></span></q></dt></tr></i><div id='DpZBg'><tfoot id='DpZBg'></tfoot><dl id='DpZBg'><fieldset id='DpZBg'></fieldset></dl></div>

                    <tbody id='DpZBg'></tbody>

                    • <legend id='DpZBg'><style id='DpZBg'><dir id='DpZBg'><q id='DpZBg'></q></dir></style></legend>
                        <bdo id='DpZBg'></bdo><ul id='DpZBg'></ul>

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

                          <tfoot id='DpZBg'></tfoot>