You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Curious if there is a reason why pygments isn't called out as a dependency. Took a while to run this down as I had prettified JSON in my local development environment, but unstyled JSON fields in the admin for my production site. The reason came down to that my local development environment had extra packages that ended up installing pygments as one of their dependencies. Add pygments to by production dependencies and viola, pretty JSON.
No pygments:
With pygments:
The text was updated successfully, but these errors were encountered:
randykleinman
changed the title
Pygments not installedl; causes issues with JSON fields
Pygments not installed; causes issues with JSON fields
Jan 3, 2025
Hey Randy, yes you are right, the Pygments library is required to provide highlighting. By default, Unfold does not require to have this library installed and it silently skips highlighting if the library is not available. I'm not planning to add Pygments into dependencies as I want to keep dependencies minimal.
Anyway, I just created new documentation page for JSONField formatting options in admin #933 where I'm mentioning Pygments library and existing behavior. Of course, if you have idea how to improve the developer experience even more, let me know. I'm open to discuss.
Thanks @lukasvinclav , I understand wanting to keep the dependencies minimal. As long as it is documented, like in #933, I think it is great. The only other option I could think of is creating an option package like unfold[pygments]==1.2.3 or unfold[highlighting], but since this seems to be a small one-off for JSON read only fields, a note in the docs is sufficient to creating more builds and build processes.
What version of Unfold are you using?
django-unfold==0.43.0
What version of Django are you using?
Django==5.1.3
What browser are you using?
Brave/Chrome/Firefox
Did you checked changelog/commit history, if the bug is not already fixed?
Yes
Did you searched other issues, if the bug is not already fixed?
Yes
Did you checked documentation?
Yes
Are you able to replicate the bug in the demo site?
No
Repository with reproduced bug
N/A
Describe your issue
Ignoring
ImportError
s for thepygments
package when displaying JSON fields causes the field to be displayed as text, instead of as prettified JSON.Relevant code is here: https://github.com/unfoldadmin/django-unfold/blob/main/src/unfold/utils.py#L127-L133
Curious if there is a reason why pygments isn't called out as a dependency. Took a while to run this down as I had prettified JSON in my local development environment, but unstyled JSON fields in the admin for my production site. The reason came down to that my local development environment had extra packages that ended up installing pygments as one of their dependencies. Add pygments to by production dependencies and viola, pretty JSON.
No pygments:
With pygments:
The text was updated successfully, but these errors were encountered: