Improve on #69, using setdefault() and update example project
Camp site rule; leave things tidier than you found them :)fix_request_path_info
parent
08e900eb6d
commit
b5774423f7
|
|
@ -6,6 +6,14 @@ from pexp.models import *
|
||||||
class ProjectChildAdmin(PolymorphicChildModelAdmin):
|
class ProjectChildAdmin(PolymorphicChildModelAdmin):
|
||||||
base_model = Project
|
base_model = Project
|
||||||
|
|
||||||
|
# On purpose, only have the shared fields here.
|
||||||
|
# The fields of the derived model should still be displayed.
|
||||||
|
base_fieldsets = (
|
||||||
|
("Base fields", {
|
||||||
|
'fields': ('topic',)
|
||||||
|
}),
|
||||||
|
)
|
||||||
|
|
||||||
class ProjectAdmin(PolymorphicParentModelAdmin):
|
class ProjectAdmin(PolymorphicParentModelAdmin):
|
||||||
base_model = Project
|
base_model = Project
|
||||||
list_filter = (PolymorphicChildModelFilter,)
|
list_filter = (PolymorphicChildModelFilter,)
|
||||||
|
|
|
||||||
|
|
@ -411,8 +411,8 @@ class PolymorphicChildModelAdmin(admin.ModelAdmin):
|
||||||
kwargs.setdefault('form', self.base_form or self.form)
|
kwargs.setdefault('form', self.base_form or self.form)
|
||||||
|
|
||||||
# prevent infinite recursion in django 1.6+
|
# prevent infinite recursion in django 1.6+
|
||||||
if 'fields' not in kwargs and not self.declared_fieldsets:
|
if not self.declared_fieldsets:
|
||||||
kwargs['fields'] = None
|
kwargs.setdefault('fields', None)
|
||||||
|
|
||||||
return super(PolymorphicChildModelAdmin, self).get_form(request, obj, **kwargs)
|
return super(PolymorphicChildModelAdmin, self).get_form(request, obj, **kwargs)
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue