from sdi.models import ParticipantInfo f = open('names.txt', 'w') for participant in participants: f.write('%s %s, %s\n' % (participant.participant.first_name, participant.participant.last_name, participant.participant.gender)) f.close()