title: 'UserProfile' object has no attribute 'id'
body: <p>I have an update form, whem i press updated for the form to update the user profile it I get the error "'UserProfile' object has no attribute 'id'"</p>
  
  <p>my models is:</p>
  
  <pre><code>from django.db import models
  from django.db.models.signals import post_save
  from django.dispatch import receiver
  
  class UserProfile(models.Model):
     user = models.OneToOneField(User, related_name="custom_user_profile", primary_key=True)
  
     organization = models.CharField(max_length=100, default='', blank=True) 
     address_line_1 = models.CharField(max_length=100, default='', blank=True)
     address_line_2 = models.CharField(max_length=100, default='', blank=True)
     city = models.CharField(max_length=100, default='', blank=True)
     state = models.CharField(max_length=100, default='', blank=True)
     post_code = models.CharField(max_length=100, default='', blank=True)
     country = models.CharField(max_length=100, default='', blank=True)
  
  def __unicode__(self):
      return self.user.username
  
  
  @receiver(post_save, sender=User)
  def create_profile(sender, instance, created, **kwargs):
      if created:
          profile, new = UserProfile.objects.get_or_create(user=instance)
  </code></pre>
  
  <p>and my views is:</p>
  
  <pre><code>from django.shortcuts import render_to_response
  from django.shortcuts import HttpResponseRedirect
  from django.template import RequestContext
  from django.core.context_processors import csrf
  from django.contrib.auth.decorators import login_required
  from user_profile.models import UserProfile
  from django.contrib.auth.models import User
  from forms import UserProfileForm
  from django.shortcuts import redirect
  
  @login_required 
  def update_profile(request):
      userProfile = UserProfile.objects.get(user=request.user)
  
      form = UserProfileForm(initial={
  
          'organization':userProfile.organization,
          'address_line_1':userProfile.address_line_1,
          'address_line_2':userProfile.address_line_2,
          'city':userProfile.city,
          'state':userProfile.state,
          'post_code':userProfile.post_code,
          'country':userProfile.country,
        })
      return render_to_response('user_profile/update_profile.html', {'form':form}, RequestContext(request))
  
  
  @login_required 
  def profile(request, profile_id):
      if profile_id == "0":
          if request.user.is_authenticated:
              userProfile = UserProfile.objects.get(user=request.user)
  
      else:
          userProfile = UserProfile.objects.get(pk=profile_id)
  
      return render_to_response('user_profile/profile.html', {'userProfile':userProfile}, RequestContext(request))
  
  
  @login_required 
  def send_update_profile(request):
      if request.method == 'POST':
          form = UserProfileForm(request.POST)
          if form.is_valid():
              userProfile = UserProfile.objects.get(user=request.user)
  
  
              organization = form.cleaned_data['organization']
              userProfile.organization = organization
  
              address_line_1 = form.cleaned_data['address_line_1']
              userProfile.address_line_1 = address_line_1
  
              address_line_2 = form.cleaned_data['address_line_2']
              userProfile.address_line_2 = address_line_2
  
              city = form.cleaned_data['city']
              userProfile.city = city
  
              state = form.cleaned_data['state']
              userProfile.state = state
  
              post_code = form.cleaned_data['post_code']
              userProfile.post_code = post_code
  
              country = form.cleaned_data['country']
              userProfile.country = country
  
              userProfile.save()
              return redirect('/user/profile/' + str(userProfile.id))
  
          else:
              form = UserProfileForm()
  
          return redirect('/user/send_update_profile/')
  </code></pre>
  
  <p>I can not work out why. One thing is that in admin.py, if i try to add 'id' as list display. An error occurs saying that there is no id in the user profile I am creating. Though, i thought an id field is automatically created when a model is created.</p>
  
  <p>Any suggestions?</p>