title: Django - post_init signal is called on Model instance save & before instance is even created. Why?
body: <p>I am trying to write a small application that receives video files, and convert them to a uniform format after they have been uploaded (thus added to the database). I have searched the web for the best solution for this, and have decided to use Django's signals with <a href="http://celeryproject.org/" rel="noreferrer">Celery</a>. But for now I'm trying to create a proof-of-concept to see if it works.</p>
  
  <p>I'm trying to execute a <code>video_repalce()</code> method after a new video has been uploaded (thus, a new row has been added to database). But the signal doesn't work right, or I didn't understand how the whole system works.</p>
  
  <p>I'm using <em>Django 1.2.3</em> with pre-defined signal <code>django.db.models.signals.post_init</code>, which <a href="http://docs.djangoproject.com/en/1.2/ref/signals/#django.db.models.signals.post_init" rel="noreferrer"><em>should</em> be called after a model has been instantiated</a> (thus, a new row was added to the database).</p>
  
  <pre><code>from django.core.files.base import File
  from django.db.models.signals import post_init
  import os
  import os.path
  import subprocess
  
  class Project(models.Model):
      video = models.FileField(upload_to="projects/videos")
  
      def replace_video(self):
          """Replace original video with an updated one."""
  
          # Video conversion process code goes here,
          # resulting in a new external video file.
  
          self.video.delete() # Delete the original video.
          self.video.save("newfile.webm", File(open("path/to/newfile.webm") ,"wb"))) # Save the new video instead.
  
          self.save() # Commit everything to database.
  
          os.remove("path/to/newfile.webm") # Remove original video copy after it was commited (copied) into the DB.
  
  # ...
  # ...
  
  def handle_new_project(sender, **kwargs): 
      """Handels some additional tasks for a new added project. i.e. convert video to uniform format."""
  
      project = kwargs['instance']
      project.replace_video()
  
  # Call 'Project.replace_video()' every time a new project is added.
  post_init.connect(handle_new_project, sender=Project, dispatch_uid="new_project_added")
  </code></pre>
  
  <p>However, post_init is called <em>not only</em> when a new model instance is created, but also...:</p>
  
  <ol>
  <li>Before the model is even instantiated. What I mean is, it's called when I exeucte the server for the first time, when there's not even a single row of data in the database (thus, no Model objects should be instantiated). The instance's <code>self.pk</code> is <code>None</code>!</li>
  <li>When <code>save()</code>-ing a model. The code above is also executed when I hit <code>self.save()</code>.</li>
  </ol>
  
  <p>Practically, it not working according to the docs.</p>
  
  <p>What am I doing wrong? Remember that this is a proof-of-concept. I intend to move the code to <a href="http://celeryproject.org/" rel="noreferrer">Celery</a> after I see it's working. But, if the signals don't work right, <a href="http://celeryproject.org/" rel="noreferrer">Celery</a> won't help - The signal will always be resent a couple of times whenever I <code>save()</code> or update a video.</p>
  
  <p>Do you think I shouldn't call <code>save()</code> inside the <code>replace_video()</code> method? So where should I call it? Which signal should I choose? <code>post_save</code> isn't a good option because it's also called whenever I hit <code>save()</code>.</p>