Django - Did you forget to register or load this tag?

前端 未结 9 2065
我寻月下人不归
我寻月下人不归 2020-12-30 00:04

I\'ve created a custom tag that I want to use, but Django can\'t seem to find it. My templatetags directory is set up like this:

pygmentize

相关标签:
9条回答
  • 2020-12-30 00:10

    In gameprofile.html please change the tag {% endblock content %} to {% endblock %} then it works otherwise django will not load the endblock and give error.

    0 讨论(0)
  • 2020-12-30 00:10

    You need to change:

    {% endblock content %}
    

    to

    {% endblock %}
    
    0 讨论(0)
  • 2020-12-30 00:15

    The app that contains the custom tags must be in INSTALLED_APPS. So Are you sure that your directory is in INSTALLED_APPS ?

    From the documentation:

    The app that contains the custom tags must be in INSTALLED_APPS in order for the {% load %} tag to work. This is a security feature: It allows you to host Python code for many template libraries on a single host machine without enabling access to all of them for every Django installation.

    0 讨论(0)
  • 2020-12-30 00:16
    {% load static %}
    <img src="{% static "my_app/example.jpg" %}" alt="My image">
    

    in your templates, use the static template tag to build the URL for the given relative path using the configured STATICFILES_STORAGE.

    0 讨论(0)
  • 2020-12-30 00:22
    {% load static %}
    

    Please add this template tag on top of the HTML or base HTML file

    0 讨论(0)
  • 2020-12-30 00:28

    The error is in this line: (% load pygmentize %}, an invalid tag. Change it to {% load pygmentize %}

    0 讨论(0)
提交回复
热议问题