Skip to content

Conversation

@p-r-a-v-i-n
Copy link
Contributor

fixes #191

Comment on lines 52 to 63
"<pre style='white-space: pre-wrap; "
"font-family: monospace; max-width: 100%;'>"
"{}"
"</pre>",
Copy link
Contributor Author

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.

@p-r-a-v-i-n p-r-a-v-i-n marked this pull request as draft December 19, 2025 12:04
) -> list[Any]:
fields = [f.name for f in self.model._meta.fields]
if "traceback" in fields:
fields.remove("traceback")
Copy link
Contributor Author

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(
Copy link
Contributor Author

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 p-r-a-v-i-n marked this pull request as ready for review December 19, 2025 12:32
Copy link
Contributor Author

@p-r-a-v-i-n p-r-a-v-i-n left a comment

Choose a reason for hiding this comment

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

Before:
original

After:
modified

@p-r-a-v-i-n
Copy link
Contributor Author

not able to figure out why CI failed.

======================================================================
FAIL: test_interrupt_signals (tests.tests.test_database_backend.DatabaseWorkerProcessTestCase.test_interrupt_signals) [2]
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/runner/work/django-tasks/django-tasks/tests/tests/test_database_backend.py", line 1525, in test_interrupt_signals
    self.assertEqual(result.status, TaskResultStatus.RUNNING)
AssertionError: TaskResultStatus.READY != TaskResultStatus.RUNNING

----------------------------------------------------------------------
Ran 223 tests in 35.656s

FAILED (failures=1, skipped=8)
Preserving test database for alias 'default' ('/Users/runner/work/django-tasks/django-tasks/db-test.sqlite3')...
Used shuffle seed: 7410681148 (generated)
error: Recipe `test` failed on line 8 with exit code 1

self, request: HttpRequest, obj: DBTaskResult | None = None
) -> list[Any]:
fields = [f.name for f in self.model._meta.fields]
if "traceback" in fields:
Copy link
Owner

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?

Copy link
Contributor Author

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; "
Copy link
Owner

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.

Copy link
Contributor Author

@p-r-a-v-i-n p-r-a-v-i-n Dec 19, 2025

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

if not obj.traceback:
return "-"
return format_html(
"<pre>{}</pre>",
Copy link
Contributor Author

@p-r-a-v-i-n p-r-a-v-i-n Dec 19, 2025

Choose a reason for hiding this comment

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

IMO adding extra css does not make any difference here, so keeping simple. but happy iterate if require

new_traceback

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Missing traceback indentation in admin

2 participants