TypeError object is not iterable
You can't iter over a model instance. I recommend you use your commented code.
If you still want to use a forloop, maybe you can add this code:
class Householdmember(models.Model):
# all yuur fields...
def __iter__(self):
return return [field.value_to_string(self) for field in Householdmember._meta.fields]
But, no one recommend that
That's better:
class Householdmember(models.Model):
# all yuur fields...
def __iter__(self):
return [ self.first_name,
self.middle_name,
self.last_name,
self.national_id,
self.get_male_display,
self.date_of_birth,
self.get_rel_to_head_display,
self.get_disability_display ]