title: Django get_or_create does not return a usable Model object in clean method of ModelForm
body: <p>Hello,</p>
  
  <p>I have bound a ModelForm to one of my model that contains a ForeignKey to another model everything driven by a CreateView. What I want to achieve is to create the model object corresponding to the foreign key if it doesn't exist before the form is overall validated and the final object created in database.</p>
  
  <p>Below the models I use:</p>
  
  <pre class="lang-py prettyprint-override"><code>class UmsAlerting(models.Model):
       alert_id = models.IntegerField(primary_key=True, editable=False)
       appli = models.ForeignKey('UmsApplication')
       env = models.ForeignKey('UmsEnvironment')
       contact = models.ForeignKey('UmsContacts')
       custom_rule = models.ForeignKey('UmsCustomRules', null=True, blank=True)
  
  class UmsApplication(models.Model):
       appli_id = models.IntegerField(primary_key=True)
       trigram_ums = models.CharField(max_length=4L)
  
  class UmsContacts(models.Model):
       contact_id = models.IntegerField(primary_key=True)
       mail_addr = models.CharField(max_length=100L)
  
  class UmsEnvironment(models.Model):
       env_id = models.IntegerField(primary_key=True)
       env_name = models.CharField(max_length=5L)
  </code></pre>
  
  <p>The model bound to the form is <code>UmsAlerting</code>. The model object I want to create if it doesn't exist is <code>UmsContacts</code>. I managed to use the field's <code>clean</code> method in my <code>ModelForm</code> of the contact field and use the get_or_create method like below:</p>
  
  <pre class="lang-py prettyprint-override"><code>def clean_contact(self):
       data = self.cleaned_data['contact']
       c, _ = UmsContacts.objects.get_or_create(mail_addr=data)
       return c
  </code></pre>
  
  <p>It perfectly works when the contact is already in the database but when it needs to be created my form return a <code>ValidationError</code> on the contact field saying "This field cannot be null". If I submit the same form a second time without changing anything the <code>UmsAlerting</code> object is well created with no validation error.</p>
  
  <p>My guess is that, for a reason I don't get, when <code>get_or_create</code> is used to create a <code>UmsContacts</code> object it cannot be used to create the new <code>UmsAlerting</code> object. So in <code>clean_contact</code> method the get is working and returns the <code>UmsContacts</code> object but the create part doesn't. It'd be like the <code>UmsContacts</code> object is saved when the whole form is validated but not before as I'd want it to.</p>
  
  <p>Anyone could help me find out what is the problem ? Is using the clean method not the best idea ? Is there another strategy to use to take around this problem ?</p>
  
  <p>Thanks in advance for your help.</p>