class MyUserAdmin(UserAdmin):
list_display = UserAdmin.list_display + ('get_company',)
list_filter = UserAdmin.list_filter + ('get_company',)
inlines = [CompanyInline,]
def get_company(self, obj):
assignment = UserCompanyAssignment.objects.get(user__exact=obj.id)
return assignment.company.name
get_company.short_description = 'Company'
Le filtre_list ne fonctionne pas avec 'get_company'. Il ditDjango - list_filter ne fonctionne pas avec les méthodes
'MyUserAdmin.list_filter[3]' refers to field 'Company' that is missing from model 'User'.
Des suggestions?
Y at-il FilterSpec disponible? –
Oui, voir http://code.djangoproject.com/svn/django/trunk/django/contrib/admin/filterspecs.py pour le code, et ces deux extraits: http://djangosnippets.org/snippets/1051/ http://djangosnippets.org/snippets/1963/ Je ne les ai pas utilisés moi-même, donc je ne peux pas me porter garant pour eux. – knutin