I am familiar with calling the currently logged in user, using: requestcontext, user, and get_profile.
What if I am creating another page, not of the currently logged in user?
my url is:
r'^/profile/(\w+)/$'
and view is as follows:
from django.contrib.auth.models import User
def profile(request, username):
person = User.objects.filter(username=username)
return render_to_response('profile.html', {"person":person},
context_instance=RequestContext(request))
In my template, I can enter {{user.username}} or {{user.get_profile.name}} and get values, but not {{person.username}} or {{person.get_profile.name}}. What is a way that I can retrieve the information I need? Thank you in advance.
.filterreturns a list, even if it just has one match. Since you’re looking for exactly one username, use.get(username=username), and your person will end up with just the one object.