0

I created two classes in admin.py referred to the same class in models.py. I have trouble because it says "register() takes at most 3 arguments (4 given)".

these are my two classes in admin.py:

class Tesi_AvailableAdmin (admin.ModelAdmin):
    model=Tesi
    fieldsets = (
                (None, {
                       'fields': ('Teacher', 'Title', 'Description', 'Date')
                        }),
                 )


    list_filter = ['Date']
    search_fields = ['Teacher', 'Title', 'Description']

    def queryset(self, request):
        qs=super(Tesi_AvailableAdmin, self).queryset(request)
        return qs.filter(State='Available')

class Tesi_RequestAdmin (admin.ModelAdmin):
    models=Tesi
    fieldsets = (
     (None, {
        'fields': ('Teacher', 'Title', 'Description', 'Date', 'Student')
            }),
    )
    list_filter = ['Date']
    search_fields = ['Teacher', 'Title', 'Description'] 

    def queryset(self, request):
        qs=super(Tesi_RequestAdmin, self).queryset(request)
        return qs.filter(State='Request')

admin.site.register(Tesi,Tesi_AvailableAdmin)
admin.site.register(Tesi_RequestAdmin)

I can't understand what should I say to register both classes of admin.py referred to the same class in model.py.

Thank you!

  • Either duplicate of http://stackoverflow.com/questions/2223375/multiple-modeladmins-views-for-same-model-in-django-admin or at least you should refer to this for a possible answer – Foon Apr 02 '14 at 11:02

2 Answers2

0

You are missing a qoute mark in your Tesi_RequestAdmin class. At this line:

search_fields = [Teacher', 'Title', 'Description'] 
Mihai Zamfir
  • 2,167
  • 4
  • 22
  • 37
  • that one was a problem of copy-paste...my code doesn't work for the admin.site.register() and I can't understand how I can fix it – user3375694 Apr 02 '14 at 11:49
0

Please append quote before teacher into search_fields..


search_fields = ['Teacher', 'Title', 'Description']
Prashant Gaur
  • 9,540
  • 10
  • 49
  • 71