Closed ystekno closed 1 year ago
sanic web framerwork jinja2 tortoise orm
Doesn't show safe filter tag on TextField value.
{{ obj.address_line|safe }} {{ obj.address_line|e }} {{ obj.address_line|escape }}
I tried these, it didn't work.
from sanic import Sanic from tortoise.contrib.sanic import register_tortoise from sanic_ext import render from models import * app = Sanic("wbserver") register_tortoise( app, db_url='postgres://postgres:root@localhost:5432/myweb', modules={'models': ['models']}, #generate_schemas=True ) @app.get("/") @app.ext.template("home.html") async def home(request): obj = await Customer.get(id=1) return {"obj": obj} if __name__ == "__main__": app.run(host="0.0.0.0", port=8000, debug=True, auto_reload=True)
{% extends "base.html" %} {% block body %} <div class="container"> <div class="row"> <h5>Customer Detail</h5> <p> {{ obj.address_line|safe }} </p> </div> </div> {% endblock body %}
Environment:
Newlines are not rendered in html, you need to use css or cover then to br tags. This isn't a jinja behavior.
sanic web framerwork jinja2 tortoise orm
Doesn't show safe filter tag on TextField value.
{{ obj.address_line|safe }} {{ obj.address_line|e }} {{ obj.address_line|escape }}
I tried these, it didn't work.
Environment: