Is this not a tuple?

前端 未结 4 707
旧时难觅i
旧时难觅i 2021-01-18 12:35

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.

Isn\'

4条回答
  •  半阙折子戏
    2021-01-18 12:58

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

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

提交回复
热议问题