views:

38

answers:

2

In my admin.py i have:

class SayfaAdmin(admin.ModelAdmin):
    def queryset(self, request):
        qs = super(SayfaAdmin, self).queryset(request)
        ....

But, insteead of defining same queryset function, i wish to write a function which will be called within admin class and returns the result so, instead of writing something as above, i wish to write:

class SayfaAdmin(admin.ModelAdmin):
    def queryset(self, request):
        qs = somefunc()

def somefunc():
    ...
    return somevalue

My problem is, how acn i get modelAdmin class (SayfaAdmin in my example), so i can call the fuction with parameters (request, self and modeladmin) ?

+1  A: 

Why can't you call it with self?

def queryset(self, request):
   return somefunc(self, request)



def somefunc(obj, request):
    ...
Daniel Roseman
A: 

qs = super(type(self), self).queryset(request)

instead of using Admin object, writing type(self) gives the same result...

FallenAngel