1👍
✅
userprofile
is actually not available when it’s referenced in your views.py, so it should raise NameError
If I understood you right, the way to achieve this is:
#views.py
def UserProfileView(request):
context_dict = {}
usercompany = get_object_or_404(Company, userprofile__user=request.user)
context_dict = {'usercompany': usercompany}
return render_to_response('profile_detail.html', context_dict, RequestContext(request))
Source:stackexchange.com