0

I have two classes in my admin.py. Because I can't register them twice, I don't know how to fix my problem. It says: "register() takes at most 3 arguments (4 given)". This is my code:

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)

Do you know how I can register all the classes? Thank you!

alecxe
  • 462,703
  • 120
  • 1,088
  • 1,195
  • 2
    Why are you defining two admin classes for a single model class? – arulmr Apr 06 '14 at 15:48
  • I need these two classes referred to the same class in models.py. These two classes have different states so, according to the state you will see one class or another. That's why I need two classes for a single model class – user3375694 Apr 06 '14 at 16:01
  • You should definitely go through docs first. **Thoroughly**. – xyres Apr 06 '14 at 17:52
  • Based on what conditions you want to filter the queryset? – arulmr Apr 06 '14 at 18:08
  • Take a look at this solution. I think it's what you're looking to do. http://stackoverflow.com/a/2228821/1637351 – schillingt Apr 07 '14 at 01:13

0 Answers0