title: add field first_name and last_name in django-profile
body: <p>I need  add the <code>first_name</code> and <code>last_name</code> fields associated with
   that <code>User</code> model and display it in the profile <code>form</code>.</p>
  
  <p><em><strong>fields:</em></strong></p>
  
  
  
  <pre><code>   &gt;&gt;&gt; user = User.objects.get(pk=1)
     &gt;&gt;&gt; user.first_name
         u'Some'
     &gt;&gt;&gt; user.last_name
         u'User'
  </code></pre>
  
  <p><em><strong>My model is something like this :</em></strong></p>
  
  
  
  <pre><code>class UserProfile(models.Model):
    user = models.ForeignKey(User, unique=True)
    personal_email = models.EmailField(blank=True)
    address = models.CharField(max_length=140)
    phone_number = models.CharField(max_length=20)
  
    def __unicode__(self):
        return u'Profile of user: %s' % self.user.username
  </code></pre>
  
  <p>when rendering the profile form, would have to show the fields.</p>
  
  <pre><code>first_name:  
  last_name: 
  personal_email:  
  address: 
  phone_number:
  </code></pre>
  
  <p><strong>Edit</strong></p>
  
  <p><em>I resolved to</em>:</p>
  
  <p>#forms.py</p>
  
  
  
  <blockquote>
  <pre class="lang-py prettyprint-override"><code>class UserProfileForm(forms.ModelForm):
      first_name = forms.CharField(max_length=30)
      last_name = forms.CharField(max_length=30)
  
      def __init__(self, *args, **kwargs):
          super(UserProfileForm, self).__init__(*args, **kwargs)
          self.fields['first_name'].initial = self.instance.user.first_name
          self.fields['last_name'].initial = self.instance.user.last_name
  
          self.fields.keyOrder = [
              'first_name',
              'last_name',
              'personal_email',
              'address',
              'phone_number',
              ]
  
  
      def save(self, *args, **kwargs):
          super(UserProfileForm, self).save(*args, **kwargs)
          self.instance.user.first_name = self.cleaned_data.get('first_name')   
          self.instance.user.last_name = self.cleaned_data.get('last_name')
          self.instance.user.save()
  
      class Meta:
          model = UserProfile
  </code></pre>
  </blockquote>
  
  <p>#urls.py</p>
  
  
  
  <blockquote>
  <pre><code>     url(r'^profiles/edit/', edit_profile, {'form_class': UserProfileForm},
                                               name='profiles_edit_profile'  ),
  </code></pre>
  </blockquote>
  
  <p>and add in #signals.py </p>
  
  
  
  <pre><code>    @receiver(post_save, sender=User)
      def create_profile(sender, instance, created, **kwargs):
          if created:
              userprofile, new = UserProfile.objects.get_or_create(user=instance)
  </code></pre>