2π
I just answered a similar question on SO, and it seems like it might solve your problem as well (if by chance youβre still looking for an answer three years later).
I wrote a template filter to parse the custom internal link format in the Textfield before display. Iβm using Markdown to parse my textfields, so I made the links return in Markdown format, but they could easily be written as HTML instead.
Update: I posted a revised version on djangosnippets.org that resolves internal links inside a markdown-formatted link, as well as on their own.
0π
if I got your problem, you should use a custom template processor to pass a dictionary to your templates:
in settings.py:
TEMPLATE_CONTEXT_PROCESSORS = (
"django.core.context_processors.auth",
"django.core.context_processors.debug",
"django.core.context_processors.i18n",
"django.core.context_processors.media",
"myapp.myprocessor.foo",
)
in myapp/myprocessor.py:
from django import template
def foo(request):
ProjectA = get_Project_from_database
t = template.Template(ProjectA.html)
c = template.Context({'name': ProjectA.name})
rendered_ProjectA = t.render(c)
return { 'rendered_ProjectA': rendered_ProjectA }
or if you donβt wanna use Django template system you can use regular expressions (import re)
- [Answered ]-Filtering using URL with DRF
- [Answered ]-Trying to do a POST request from node.js to Django
- [Answered ]-Django. File field name