In the template, you cannot access the attributes or functions of __underscored__. Instead, you create a function in your model / class:
class Person(models.Model):
first_name = models.CharField(max_length=256)
last_name = models.CharField(max_length=256)
def attrs(self):
for attr, value in self.__dict__.iteritems():
yield attr, value
def sorted_attrs(self):
return [(key, self.__dict__[key]) for key in sorted(self.__dict__)]
In the template, this is simple:
<tr>
{% for name, value in person.attrs %}
<td>{{name}}</td>
<td>{{value}}</td>
{% endfor %}
</tr>
"first_name" "First", . , mixin, ..
, , :
{% for person in persons %}
<tr>
{% for name, value in person.attrs %}
<td>{{name}}</td>
<td>{{value}}</td>
{% endfor %}
</tr>
{% endfor %}