I have very long code in one line, like this
{% for student_id, name, gender, family_description, grade, class, date in report_info %}
Can I break that into two lines using slash or other symbol?
Whenever I find myself trying to coerce Django's templating system to short-cut long lines of code like this, it's almost always a red-flag for me to rethink my data structure.
Perhaps you can consider changing report_info
so that each item in report_info
is actually a dict, or a class.
report_info = [
{"student_id": id, "name": name, "gender": gender, ...},
...
]
And then in your template, the iteration is simple, and not long:
{% for report_item in report_info %}
{{ report_item.student_id }}
{{ report_item.name }}
...
{% endfor %}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With