2

I'm using Django for a project, and I want to use a couple of apps that extend the admin by subclassing the admin class.

How can I have them both sublass the admin class?

from django.contrib import admin
from testing.models import *
from reversion.admin import VersionAdmin
from moderation.admin import ModerationAdmin

class ItemAdmin(VersionAdmin):
    pass

admin.site.register(Item, ItemAdmin)
1
  • You can't subclass a module. Subclassing is... erm... for classes. Is class ItemAdmin(VersionAdmin, ModerationAdmin) what you want? (I doubt it.) If so, why doesn't it work? Commented Feb 6, 2011 at 18:42

1 Answer 1

4

Both VersionAdmin and ModerationAdmin appear to use the "cooperative super" feature of Python. So I'd try to just use multiple inheritance:

class ItemAdmin(VersionAdmin, ModerationAdmin):
    pass

If this fails, you can see whether it works better with the reverse order. If this still fails, you need to study the specific issue, and find out why the cooperative super doesn't work.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.