J'ai un errror: 'run_target' est pas une bibliothèque de balises valide: Template Library run_target introuvable, a essayé django.templatetags.run_targetfiltre modèle Django personnalisé ne peut pas travailler
Je ne sais pas pourquoi ça ne marche pas, même si j'ajoute 'db.templatefilters' ça ne marche pas trop ... Quelqu'un peut-il m'aider? Thank you :)
Ci-dessous ma structure de fichier:
db/
models.py
templatefilters/
__init__.py
run_target.py
templates/
run.html
run_target.py
from django import template
register = template.Library()
@register.simple_tag
def dictKeyLookup(the_dict, key):
return the_dict[key]
run.html
{% extends "index.html" %}
**{% load run_target %}**
{% block content %}
<div style="margin-left:150px; margin-top:10px">
<a href="/home">Home</a> >> <b>run</b>
</div>
<form name="form" method="post">
<br>
<input type="submit" value="Delete" style="margin-left:149px; width:80px; height:30px">
<table border="1"; style="margin-left:150px; border-collapse:collapse;margin-top:10px"; cellpadding="4" borderColor=black>
{% for run in run_list %}
<tr>
<td>{% dictKeyLookup target_dict run.id %}</td>
</tr>
{% endfor %}
</table>
</form>
{% endblock %}
merci pour votre réponse, je ne sais pas le nom du dossier 'templatetags' ne peut pas être changé, merci encore :) – LoveTW
et n'oubliez pas de redémarrer le serveur ... semble trivial, mais c'était mon problème –
Redémarrer le serveur a fonctionné pour moi. –