title: 'WSGIRequest' object has no attribute 'user'
body: <p>I'am trying to make an auth module in my django project. But when I open my web site url I have a this error: 'WSGIRequest' object has no attribute 'user'</p>
  
  <p>I've trying to find information about this problem and somebody said that the problem is in MIDDLEWARE_CLASSES but I can't understand it.</p>
  
  <p>This is my MIDDLEWARE_CLASSES:</p>
  
  <pre><code>MIDDLEWARE_CLASSES = (
      'django.contrib.sessions.middleware.SessionMiddleware',
      'django.middleware.common.CommonMiddleware',
      #'django.middleware.csrf.CsrfViewMiddleware',
      'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
      'django.contrib.auth.middleware.AuthenticationMiddleware',
      'django.contrib.messages.middleware.MessageMiddleware',
      'django.middleware.clickjacking.XFrameOptionsMiddleware',
  )
  </code></pre>
  
  <p>myproject/admin.py</p>
  
  <pre><code>from django.contrib import admin
  from personal_area.models import UserProfile
  
  admin.site.register(UserProfile)
  </code></pre>
  
  <p>myproject/forms.py</p>
  
  <pre><code>from personal_area.models import UserProfile
  from django.contrib.auth.models import User
  from django import forms
  
  
  class UserForm(forms.Model):
      password = forms.CharField(widget=forms.PasswordInput())
  
      class Meta:
          model = User
          fields = ('username', 'email', 'password')
  
  
  class UserProfileForm(forms.ModelForm):
      class Meta:
          model = UserProfile
          fields = ('website', 'picture')
  </code></pre>
  
  <p>myproject/models.py</p>
  
  <pre><code>from django.db import models
  from django.contrib.auth.models import User
  
  
  class UserProfile(models.Model):
  
      user = models.OneToOneField(User)
  
      website = models.URLField(blank=True)
      picture = models.ImageField(upload_to='profile_images', blank=True)
  
      def __unicode__(self):
          return self.user.username
  </code></pre>
  
  <p>myproject/views.py</p>
  
  <pre><code>from django.shortcuts import render, render_to_response, HttpResponseRedirect, RequestContext
  from django.contrib import auth
  
  from personal_area.forms import UserForm, UserProfileForm
  
  
  def register(request):
  
      context = RequestContext(request)
      registered = False
  
      if request.method == 'Post':
          user_form = UserForm(data = request.POST)
          profile_form = UserProfileForm(data = request.POST)
  
          if user_form.is_valid() and profile_form.is_valid():
              user = user_form.save()
  
              user.set_password(user.password)
              user.save()
  
              profile = profile_form.save(commit = False)
              profile.user = user
  
              if 'picture' in request.FILES:
                  profile.picture = request.FILES['picture']
  
              profile.save()
              registered = True
  
          else:
              print(user_form.errors, profile_form.errors)
  
      else:
          user_form = UserForm()
          profile_form = UserProfileForm()
  
      return render_to_response('personal_area/register.html', {'user_form': user_form, 'profile_form': profile_form,
                                                                'registered': registered}, context)
  </code></pre>
  
  <p>myproject/register.html</p>
  
  <pre><code>{% extends "home/base.html" %}
  
   {% block auth %}
          &lt;h1&gt;Register with Rango&lt;/h1&gt;
  
          {% if registered %}
          Rango says: &lt;strong&gt;thank you for registering!&lt;/strong&gt;
          &lt;a href="/personal_area/"&gt;Return to the homepage.&lt;/a&gt;&lt;br /&gt;
          {% else %}
          Rango says: &lt;strong&gt;register here!&lt;/strong&gt;&lt;br /&gt;
  
          &lt;form id="user_form" method="post" action="/personal_area/register/"
                  enctype="multipart/form-data"&gt;
  
              {% csrf_token %}
  
              {{ user_form.as_p }}
              {{ profile_form.as_p }}
  
              &lt;input type="submit" name="submit" value="Register" /&gt;
          &lt;/form&gt;
          {% endif %}
  {% endblock %}
  </code></pre>
  
  <p>This is tutorial for my module:</p>
  
  <p><a href="http://www.tangowithdjango.com/book/chapters/login.html#linking-together" rel="nofollow">http://www.tangowithdjango.com/book/chapters/login.html#linking-together</a></p>