Make the admin base_model setting optional.
It can be detected using get_base_polymorphic_model()
This commit is contained in:
@@ -4,13 +4,13 @@ from pexp.models import *
|
||||
|
||||
|
||||
class ProjectAdmin(PolymorphicParentModelAdmin):
|
||||
base_model = Project
|
||||
base_model = Project # Can be set explicitly.
|
||||
list_filter = (PolymorphicChildModelFilter,)
|
||||
child_models = (Project, ArtProject, ResearchProject)
|
||||
|
||||
|
||||
class ProjectChildAdmin(PolymorphicChildModelAdmin):
|
||||
base_model = Project
|
||||
base_model = Project # Can be set explicitly.
|
||||
|
||||
# On purpose, only have the shared fields here.
|
||||
# The fields of the derived model should still be displayed.
|
||||
@@ -27,13 +27,12 @@ admin.site.register(ResearchProject, ProjectChildAdmin)
|
||||
|
||||
|
||||
class UUIDModelAAdmin(PolymorphicParentModelAdmin):
|
||||
base_model = UUIDModelA
|
||||
list_filter = (PolymorphicChildModelFilter,)
|
||||
child_models = (UUIDModelA, UUIDModelB)
|
||||
|
||||
|
||||
class UUIDModelAChildAdmin(PolymorphicChildModelAdmin):
|
||||
base_model = UUIDModelA
|
||||
pass
|
||||
|
||||
|
||||
admin.site.register(UUIDModelA, UUIDModelAAdmin)
|
||||
@@ -42,13 +41,12 @@ admin.site.register(UUIDModelC, UUIDModelAChildAdmin)
|
||||
|
||||
|
||||
class ProxyAdmin(PolymorphicParentModelAdmin):
|
||||
base_model = ProxyBase
|
||||
list_filter = (PolymorphicChildModelFilter,)
|
||||
child_models = (ProxyA, ProxyB)
|
||||
|
||||
|
||||
class ProxyChildAdmin(PolymorphicChildModelAdmin):
|
||||
base_model = ProxyBase
|
||||
pass
|
||||
|
||||
|
||||
admin.site.register(ProxyBase, ProxyAdmin)
|
||||
|
||||
Reference in New Issue
Block a user