How to pass a username from a Django login form?
<p>This will be an easy question for someone out there. I searched around quite a bit and if there's a thread that addresses this perfectly, please direct me and close this out. I'm building a very simple web form within our organization's website using Django. </p>

<p>In forms.py I've got a class for the login page:</p>

<pre><code>class userLogin(forms.Form):

    user = forms.CharField(label = 'Username ', max_length = 25)
    pwd  = forms.CharField(label = 'Password ', widget = forms.PasswordInput)

    def clean(self):

        cleaned_data = super(userLogin, self).clean()
        user         = cleaned_data.get("user")
        pwd          = cleaned_data.get("pwd")

        if not fs.authenticateUser(user, pwd):
            raise forms.ValidationError("Invalid password!")
</code></pre>

<p>I have to authenticate against our website's API, which is what the fs.authenticate bit is about; it just returns True or False. In views.py I do this:</p>

<pre><code>    if request.method == 'POST':

        user_form = userLogin(data = request.POST)

        if user_form.is_valid():            
            return redirect('PickupAuthorization/main')
        else:
            pass                    
</code></pre>

<p>The authentication and redirection to the main page works splendidly, and the login form throws an invalid password message as expected when the credential is incorrect. What I want to know is how to make "user" available to views.py. If I try to reference user_form.user in the view, Python tells me that user is not an attribute of userLogin!</p>

<p>I haven't done much with OOP, so I'm imagining that this has a simple answer, but I can't freakin' find it. Thanks!</p>

<p>EDIT: I have had to shelve this project for the moment in favor of more pressing matters, but I will update it when I have a solution that works properly.</p>