title: Django: redirect to view with parameters
body: <p>I am using Django authentication. Whenever a user logs in, I want to redirect him to /profile/user_id, being user_id a number. I can get the value of user_id by <code>request.user.profile.id</code>. In settings.py I have <code>LOGIN_REDIRECT_URL = 'app_1:index'</code></p>
  
  <p>app_1/urls.py:</p>
  
  <pre><code>url(r'^profile/$', views.index, name='index'),
  # ex: /profile/5/
  url(r'^profile/(?P&lt;user_id&gt;[0-9]+)/$', views.profile, name='profile'),
  </code></pre>
  
  <p>app_1/views.py (things I've also tried are commented):</p>
  
  <pre><code>def index(request):
      userid = request.user.profile.id
      #return render(request, 'app_1/index.html', context)
      #return profile(request, request.user.profile.id)
      #return render(request, 'app_1/user_prof.html', {'user': request.user.profile.id})
      #return redirect(profile, user_id= request.user.profile.id)
      return redirect('profile', user_id=userid)
  
  
  def profile(request, user_id):
      user = get_object_or_404(Profile, pk=user_id)
      return render(request, 'app_1/user_prof.html', {'user': user})
  </code></pre>
  
  <p>I must be missing something because this should be easy but I'm stuck on it. Thanks in advance.</p>
  
  <p>EDIT: The error I'm getting is <code>Reverse for 'profile' not found. 'profile' is not a valid view function or pattern name.</code>: <a href="http://dpaste.com/270YRJ9" rel="nofollow noreferrer">http://dpaste.com/270YRJ9</a> </p>