I have django template and I get a some object. I want apply for in cycle for all atributes this object.
{% for point in Object %}
<h1>{{ Object[point] }}</h1>
{% endfor %}
I have django template and I get a some object. I want apply for in cycle for all atributes this object.
{% for point in Object %}
<h1>{{ Object[point] }}</h1>
{% endfor %}
You can't do that in the template.
One solution is to convert your object in a dictionary in the view with object.__dict__
and then iterate over it with:
{% for attr, value in object_dict.items %}
{{ attr }} : {{ value }}
{% endfor %}
As py_dude suggests, you can discard attributes starting with underscores to keep your actual attributes.
{% for k, v in Object.__dict__.items() %}
{% if not k.startswith("_") %}
<h1>{{ v }}</h1>
{% endif %}
{% endfor %}