Is this not a tuple?

django, python, tuples

Solution

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

Problem

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

Original source