title: post_save signal with sender AUTH_USER_MODEL fires at login
body: <h1>What was done</h1>
  
  <p>I have a custom <code>User</code> model called <code>MyUser</code> as it is described in an <a href="https://docs.djangoproject.com/en/1.9/topics/auth/customizing/#a-full-example" rel="nofollow noreferrer">full example for an custom user model</a> on the docs and a so called <code>UserProfile</code> that is connected to <code>MyUser</code> by an <a href="https://docs.djangoproject.com/en/1.9/topics/db/examples/one_to_one/#one-to-one-relationships" rel="nofollow noreferrer">One-to-one relationship</a> like it's described in the Django documentation about how to <a href="https://docs.djangoproject.com/en/1.9/topics/auth/customizing/#extending-the-existing-user-model" rel="nofollow noreferrer">extend an existing user model</a>.</p>
  
  <p>In the documentation for <a href="https://docs.djangoproject.com/en/1.9/topics/auth/customizing/" rel="nofollow noreferrer">Customizing authentication</a> is an example for <a href="https://docs.djangoproject.com/en/1.9/topics/auth/customizing/#referencing-the-user-model" rel="nofollow noreferrer">how to connect a post_save signal with the existing <code>User</code> model</a>.</p>
  
  <p>By following this, I put an testing receiver in a signals.py that is loaded by my <code>apps.py</code> file, like it's described in <a href="https://stackoverflow.com/a/21612050/4946454">this</a> SO answer.</p>
  
  <h2>Configuration</h2>
  
  <h3>signal.py</h3>
  
  <pre><code>def post_save_receiver(sender, instance, created, **kwargs):
      send_mail('Testing', "Just testing...", 'hell@earth.tld', ['admin@heaven.tld'], fail_silently=False)
  
  post_save.connect(post_save_receiver, sender=settings.AUTH_USER_MODEL)
  </code></pre>
  
  <h3>models.py</h3>
  
  <pre><code>class MyUserManager(BaseUserManager):
      def create_user(self, email, password=None):
      """
          Creates and saves a User with the given email and password.
          """
          if not email:
              raise ValueError('Users must have an email address')
  
          user = self.model(
              email=self.normalize_email(email),
          )
  
          user.set_password(password)
          user.save(using=self._db)
          return user
  
      def create_superuser(self, email, password):
          """
          Creates and saves a superuser with the given email and password.
          """
          user = self.create_user(email,
              password=password,
          )
          user.is_admin = True
          user.save(using=self._db)
          return user
  
  
  
  
  class MyUser(AbstractBaseUser):
      email = models.EmailField(
          verbose_name='email address',
          max_length=255,
          unique=True,
      )
      is_active = models.BooleanField(default=True)
      is_admin = models.BooleanField(default=False)
  
      objects = MyUserManager()
  
      USERNAME_FIELD = 'email'
  
      def get_full_name(self):
          # The user is identified by their email address
          return self.email
  
      def get_short_name(self):
          # The user is identified by their email address
          return self.email
  
      def __str__(self):              # __unicode__ on Python 2
          return self.email
  
      def has_perm(self, perm, obj=None):
          "Does the user have a specific permission?"
          # Simplest possible answer: Yes, always
          return True
  
      def has_module_perms(self, app_label):
          "Does the user have permissions to view the app `app_label`?"
          # Simplest possible answer: Yes, always
          return True
  
      @property
      def is_staff(self):
          "Is the user a member of staff?"
          # Simplest possible answer: All admins are staff
          return self.is_admin
  </code></pre>
  
  <h3>views.py</h3>
  
  <pre><code>def UserLogin(request):
      if request.user.is_authenticated():
          return HttpResponseRedirect("http://www.heaven.tld/account")
      else:
          if request.method == 'POST':
              form = UserLoginForm(request.POST)
              if form.is_valid():
                  username = form.cleaned_data['username']
                  password = form.cleaned_data['password']
                  user = authenticate(username=username, password=password)
                  if user is not None and user.is_active:
                      login(request, user)
                      return HttpResponseRedirect("http://www.heaven.tld/account")
                  else:
                      error_msg = 'Please try again!'
                      return render(request, "development",
                          {'form':form,
                          'error_msg':error_msg,
                           })
              else:
                  error_msg = "Please try again!"
                  return render(request, "development",
                      {'form':form,
                      'error_msg':error_msg,
                      })
          else:
              form = UserLoginForm()
              return render(request, "development", {'form': form})
  </code></pre>
  
  <h1>The Problem</h1>
  
  <p>Now if I log in I always get this mail, but I want it only if a user was created.</p>