From one of my Flask routes I pass an object (selectedStek) to a Jinja2 template
from flask import (Blueprint, current_app, flash, jsonify, redirect, render_template, request, url_for)
from flask_login import current_user, login_required
from flask_uploads import IMAGES, UploadSet, configure_uploads
from . import db
from .forms import createStekForm
from .models import Stek, Stektype
stekken = Blueprint("stekken", __name__)
@stekken.route("/stek_modify/<stekId>", methods=['GET', 'POST'])
@login_required
def stek_modify(stekId):
form = createStekForm()
selectedStek = Stek.query.filter_by(id = int(stekId)).first()
return render_template('stek_modify.html', form=form, stek=selectedStek"])
Which I then want to use in a javascript with tojason
{% block content %}
<h3>{{stek.place}} </h3>
{% endblock %}
{% block scripts %}
<script>
$(document).ready(function () {
console.log( "ready!" );
varKo = ({{stek.place|tojson }});
console.log(varKo);
}); // document.readyFunction
</script>
{% endblock %}
This code returns an error “jinja2.exceptions.TemplateAssertionError: No filter named ‘tojason'”.
I just can’t figure out what’s wrong.
Probably something simple but I need some help to figure it out