Skip to content
Discussion options

You must be logged in to vote

Well, I figured it out with help from Grok

I added a markdown.py file like below to the folder "/home/inventree/src/backend/InvenTree/report/templatetags"

from django import template
import markdown
from django.conf import settings
import os

register = template.Library()

@register.filter
def render_markdown(value):
    html = markdown.markdown(value)
    # Replace relative /media/ paths with absolute file system paths
    media_root = settings.MEDIA_ROOT
    absolute_media_path = f"file://{os.path.abspath(media_root)}/"
    return html.replace('src="/media/', f'src="{absolute_media_path}')

After this the server needed to be restarted.

Then I added a {% load markdown %} as well as this …

Replies: 4 comments 11 replies

Comment options

You must be logged in to vote
1 reply
@matmair
Comment options

Answer selected by zwvk
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
10 replies
@matmair
Comment options

@SchrodingersGat
Comment options

@LqdBcnAtWork
Comment options

@wolflu05
Comment options

@LqdBcnAtWork
Comment options

Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
5 participants