title: View Profile page as another user in django
body: <p>So I have a <code>my user profile</code> view you can see as a logged in user. I wanted to add a second view so other logged in users can visit profile pages as well, but I'm not really sure I'm doing it the right way</p>
  
  <p>urls.py</p>
  
  <pre><code>url(r'^accounts/profile/', main_views.uprofile, name='uprofile'), #the page you see as my profile
      url(r'^profile/(?P&lt;pk&gt;\d+)/$', main_views.oprofile, name='oprofile'), # the page i use so other users can view the profile page
      url(r'^accounts/update/(?P&lt;pk&gt;\d+)/', User_Profile_views.edit_user, name='edit_user'), #Custom update profile page
  </code></pre>
  
  <p>main_views.py</p>
  
  <pre><code>@login_required(login_url='/accounts/login/')
  def uprofile (request):
  
      context = locals()  
      template = 'profile.html'
      return render (request, template, context)
  
  def oprofile (request, pk):
      user = User.objects.get(pk=pk)
  
      context = locals()  
      template = 'profile.html'
      return render (request, template, context)
  </code></pre>