Skip to content

Commit

Permalink
fix: hasattr readonly fields
Browse files Browse the repository at this point in the history
  • Loading branch information
lukasvinclav committed Aug 27, 2023
1 parent 6466304 commit abf2a48
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/unfold/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,10 @@ def _get_contents(self) -> str:
return conditional_escape(result_repr)

def _preprocess_field(self, contents: str) -> str:
if self.field["field"] in self.model_admin.readonly_preprocess_fields:
if (
hasattr(self.model_admin, "readonly_preprocess_fields")
and self.field["field"] in self.model_admin.readonly_preprocess_fields
):
func = self.model_admin.readonly_preprocess_fields[self.field["field"]]

if isinstance(func, str):
Expand Down

0 comments on commit abf2a48

Please sign in to comment.