Friday, November 30, 2012

Re: admin foreign key issues




class CategoryAdmin(admin.ModelAdmin):
    list_display = ('name')
    list_filter = ('name')
admin.site.register(Category, CategoryAdmin)

But that fails with 'CategoryAdmin.list_display' must be a list or tuple.

use:   list_display = ('name',)

Note the trailing comma, there?

In python, a tuple with a single element must use the form ( x, )  or it is indistinguishable from a parenthesised expression. 
 

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/eXAQLOj3egYJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

No comments:

Post a Comment