title: Django SAML Custom User Attributes & Save Signal
body: <p>I've successfully implemented a baseline Django/pysaml2 integration with SAML assertion using the <a href="https://pypi.python.org/pypi/djangosaml2" rel="nofollow">djangosaml2</a> package.  Users are created dynamically based on a successful authentication which is great!  Now I would like to inject a short list of custom attributes into my <a href="https://docs.djangoproject.com/en/1.6/topics/auth/customizing/#extending-the-existing-user-model" rel="nofollow">Django 1.6 "extended" user model</a>.</p>
  
  <p>The djangosaml2 documentation states (see: <a href="https://pypi.python.org/pypi/djangosaml2#user-attributes" rel="nofollow">https://pypi.python.org/pypi/djangosaml2#user-attributes</a>) that I should use the provided Django signal:</p>
  
  <blockquote>
    <p>...for these cases djangosaml2 provides a Django signal that you can
    listen to. In order to do so you can add the following code to your
    app:</p>
  </blockquote>
  
  <pre><code>from djangosaml2.signals import pre_user_save
  
  def custom_update_user(sender=user, attributes=attributes, user_modified=user_modified)
      ...
      return True  # I modified the user object
  </code></pre>
  
  <p>Here are my questions:</p>
  
  <ul>
  <li>Where do I place the above signal code?</li>
  <li>How do I tell my extended user model to set an employee id if my extended user model look like this?</li>
  </ul>
  
  <p><strong>models.py</strong></p>
  
  <pre><code>from django.db import models
  from django.contrib.auth.models import User
  
  class UserProfile(models.Model):
      user = models.OneToOneField(User)
      employee_id = models.CharField(blank=True,max_length=150)
  </code></pre>