title: DJango HttpResponseRedirect not passing "request" to function
body: <p>I am using the DJango login/authentication functionality. I have extended it with a Profile using the <a href="https://docs.djangoproject.com/en/1.11/topics/auth/customizing/" rel="nofollow noreferrer">Extending The Existing User Model</a> approach. </p>
  
  <p>In the "Profile" is a variable called <strong>restrole</strong>. In the code below, <strong>restrole</strong> is being used to control the NEXT screen the user sees (as well as as the data on it):</p>
  
  <pre><code>def user_login(request):
  
  if request.method == 'POST':
      # First get the username and password supplied
      username = request.POST.get('username')
      password = request.POST.get('password')
  
  # Django's built-in authentication function:
  user = authenticate(username=username, password=password)
  
      if user:
          # Check it the account is active
          if user.is_active:
  
              # Log the user in.
              login(request, user)
  
              myprofile = user.userprofileinfo
              restrole = myprofile.restrole
  
          if  restrole == 1:
              return HttpResponseRedirect(reverse('authinduction:induct-owner'))
          elif restrole == 2:
              return HttpResponseRedirect(reverse('authinduction:induct-office'))
          elif restrole == 3:
              return HttpResponseRedirect(reverse('authinduction:induct-customer'))
          elif restrole == 4:
              return HttpResponseRedirect(reverse('authinduction:induct-field-work'))
          else:
              return HttpResponse("Unrecognized Role") 
  </code></pre>
  
  <h1>This Part works fine</h1>
  
  <p>I can get data from the "request" variable</p>
  
  <pre><code># First get the username and password supplied
  username = request.POST.get('username') &lt;&lt;&lt; data is returned
  password = request.POST.get('password') &lt;&lt;&lt; data is returned
  </code></pre>
  
  <h1>The problem</h1>
  
  <p>When I execute one of the branches:</p>
  
  <pre><code>        if  restrole == 1:
              return HttpResponseRedirect(reverse('authinduction:induct-owner'))
  </code></pre>
  
  <p>It goes to the correct function, but "request" does not appear to have any data associated with it. Getting the "username" results in getting a value of "None"</p>
  
  <pre><code>from django.http import HttpResponseRedirect, HttpResponse
  from django.core.urlresolvers import reverse
  from authinduction.models import Mstrauthownerrdx
  from django.contrib.auth.models import User
  
  def inductowner(request):
  
      username = request.POST.get('username')  &lt;&lt;&lt; does NOT work, returns "None"
      user = User.objects.get(username=username) &lt;&lt;&lt; causes a DoNotExist error here
  </code></pre>
  
  <p>What is the best way to come around this problem?</p>
  
  <p>TIA</p>
  
  <h1>Update</h1>
  
  <p>@Alasdair - Thanks for the response. That did the trick! I noticed that the form itself accesses the user login info as follows: </p>
  
  <pre><code>&lt;input type="text" name="username" placeholder="Enter Your Logon Info"&gt;
  </code></pre>
  
  <p>As metioned above, to get the username (when doing the POST as you have noted), one does </p>
  
  <pre><code>username = request.POST.get('username')
  </code></pre>
  
  <p>In all of this, I keep seeing "username", but - to solve the problem, one users "request.user". Why is this the case? I ask because I would have never thought to use "request.user" to get the information. If anything, I would have used "request.username"</p>