-
Notifications
You must be signed in to change notification settings - Fork 49
Format traceback field to preserve indentation for readability #216
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
| "<pre style='white-space: pre-wrap; " | ||
| "font-family: monospace; max-width: 100%;'>" | ||
| "{}" | ||
| "</pre>", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Render traceback using <pre> so whitespace and indentation are preserved.
Django admin collapses whitespace for TextField values by default.
66ef385 to
357e2d3
Compare
| ) -> list[Any]: | ||
| fields = [f.name for f in self.model._meta.fields] | ||
| if "traceback" in fields: | ||
| fields.remove("traceback") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Replace the raw traceback field with a formatted admin-only field to improve
readability without changing how the data is stored.
| def formatted_traceback(self, obj: DBTaskResult) -> str: | ||
| if not obj.traceback: | ||
| return "-" | ||
| return format_html( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Used format_html() to safely render HTML while escaping the traceback content.
p-r-a-v-i-n
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
|
not able to figure out why CI failed. |
| self, request: HttpRequest, obj: DBTaskResult | None = None | ||
| ) -> list[Any]: | ||
| fields = [f.name for f in self.model._meta.fields] | ||
| if "traceback" in fields: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Question: Why would traceback not be in fields?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah, it will always be in fields.
| if not obj.traceback: | ||
| return "-" | ||
| return format_html( | ||
| "<pre style='white-space: pre-wrap; " |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Issue: Inline styles aren't ideal - could this be moved to a small CSS file.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
invoking Css file may be difficult. instead I will try it without css
357e2d3 to
db6845d
Compare
| if not obj.traceback: | ||
| return "-" | ||
| return format_html( | ||
| "<pre>{}</pre>", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
db6845d to
00f73ad
Compare



fixes #191