You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
To help IDE highlight code better, please don't use the same quote style when nesting.
Please write:
<ahref="{% url 'some_view' %}">
Don't write:
<ahref="{% url "some_view" %}">
Later on, I suggest to use djLint to lint Django template code.
Another good move is to use Jinja2 for template, because Jinja2 support more Python syntax. One typical case is that, when you want to manipulate a variable, you use filter:
{{ value|make_fancy }}
and what if you want to pass more options to make_fancy filter? With Django template, you can only pass one more option:
{{ value|make_fancy:'green' }}
But with Jinja2, you can just use Python function call syntax, and can pass as many as you want
Use Meaningful and Consistent Naming Conventions
Use clear, descriptive names for variables and blocks.
Stick to consistent naming patterns that match the project's coding style.
{% block content %}
To help IDE highlight code better, please don't use the same quote style when nesting.
Please write:
Don't write:
Later on, I suggest to use djLint to lint Django template code.
Another good move is to use Jinja2 for template, because Jinja2 support more Python syntax. One typical case is that, when you want to manipulate a variable, you use filter:
and what if you want to pass more options to
make_fancy
filter? With Django template, you can only pass one more option:But with Jinja2, you can just use Python function call syntax, and can pass as many as you want
Another good feature of Jinja2 is "macro" which let you factorize your template to reusable parts, like functions.
The text was updated successfully, but these errors were encountered: