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):
|
||||
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):
|
||||
base_model = Project
|
||||
list_filter = (PolymorphicChildModelFilter,)
|
||||
|
|
|
|||
|
|
@ -411,8 +411,8 @@ class PolymorphicChildModelAdmin(admin.ModelAdmin):
|
|||
kwargs.setdefault('form', self.base_form or self.form)
|
||||
|
||||
# prevent infinite recursion in django 1.6+
|
||||
if 'fields' not in kwargs and not self.declared_fieldsets:
|
||||
kwargs['fields'] = None
|
||||
if not self.declared_fieldsets:
|
||||
kwargs.setdefault('fields', None)
|
||||
|
||||
return super(PolymorphicChildModelAdmin, self).get_form(request, obj, **kwargs)
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue