Skip to content

Commit

Permalink
Improve fix of PR #321
Browse files Browse the repository at this point in the history
checking hasattr(self, 'fieldsets') alway returns true, and produces
different effects. The hasattr(self, 'declared_fieldsets') was designed
to detect whether Django injected that attribute.

Amends: 5e150ea
  • Loading branch information
vdboor committed Nov 20, 2017
1 parent 8f0932b commit 02b71d8
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion polymorphic/admin/childadmin.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ def history_view(self, request, object_id, extra_context=None):

def get_fieldsets(self, request, obj=None):
# If subclass declares fieldsets or fields, this is respected
if hasattr(self, 'fieldsets') or hasattr(self, 'fields') or not self.base_fieldsets:
if self.fieldsets or or self.fields or not self.base_fieldsets:
return super(PolymorphicChildModelAdmin, self).get_fieldsets(request, obj)

# Have a reasonable default fieldsets,
Expand Down

1 comment on commit 02b71d8

@tony
Copy link
Member

@tony tony commented on 02b71d8 Dec 6, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The logic in ModelAdmin is highly complex. I'm trying to see if there's a better way to do this.

Please sign in to comment.