

def extend_registered(extended_cls):
    if issubclass(extended_cls, admin.ModelAdmin):
        admin_cls = extended_cls
        admin.site.unregister(admin_cls._model_cls)
        admin.site.register(admin_cls._model_cls, admin_cls)
        return admin_cls
    elif issubclass(extended_cls, (forms.Form, forms.ModelForm)):
        form_cls = extended_cls
        admin_cls = form_cls._admin_cls
        admin.site.unregister(admin_cls._model_cls)
        admin_cls.form = form_cls
        admin.site.register(admin_cls._model_cls, admin_cls)
        return form_cls
    else:
        raise ValueError('Extended class needs to be a ModelAdmin or Form')

dataset/ETHPy150Open kux/django-admin-extend/admin_extend/extend.py extend_registered/original