table fields and values

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
@login_required
def my_profile(request):
user = User.objects.get(pk=request.user.id)
profile = user.get_profile()
field_names = [f.name for f in profile._meta.fields]
values = []
for field_name in field_names:
values.append(getattr(profile,field_name))
user_data = zip(field_names,values)
return render_to_response('profile.html',{'user_data':user_data},context_instance=RequestContext(request))