title: Django custom validate_unique method works for saving new object in admin site, but not in views and templates (`self` doesn't exist yet)
body: <p>I have a couple of models with similar validate_unique overrides, as in <a href="https://stackoverflow.com/questions/8245430/django-conditional-unique-together">this question</a>. This is in models.py:</p>
  
  <pre><code>class TeachingGroup(models.Model):
      cohort = models.ForeignKey(Cohort)
      name = models.CharField(max_length=26)
      slug = models.CharField(max_length=30, editable=False)
  
      class Meta:
          unique_together = ('cohort', 'name')
  
      def validate_unique(self, exclude = None):
          from django.core.exceptions import ValidationError, NON_FIELD_ERRORS
          slugfodder = u'%s %s' % (self.cohort.year_group.shortname, self.name)
          self.slug = slugify(slugfodder)
          options = dict(slug = self.slug, cohort__year_group__school = self.cohort.year_group.school)
          hits = TeachingGroup.objects.exclude(pk=self.pk).filter(**options)
          if hits.exists():
              template = """The name is used for database lookups,
                  and '{0}' is too similar to '{1}', as both become
                  '{2}' in your web browser's address bar."""
              message = template.format(self.name, hits[0].name, self.slug)
              raise ValidationError({NON_FIELD_ERRORS: [message]})
          super(TeachingGroup, self).validate_unique(exclude=exclude)
  </code></pre>
  
  <p>I don't have sufficient reputation to comment <a href="https://stackoverflow.com/questions/8245430/django-conditional-unique-together">over there</a>, but it seems that by adding the <code>super</code> line at the end I don't bypass the model's <code>Meta: unique_together</code> validation.</p>
  
  <p>In the interest of brevity, I've not included my model structure, but all the above validation is working fine in the admin site, both for changing existing objects (the error displays when I set the names sufficiently similar that the slug is identical) and for adding new objects.</p>
  
  <p>In the rendered web page, I get the error message as expected when changing an existing record, but oddly not when adding a new object from a form (with no instance). Instead I get a string of errors culminating in:</p>
  
  <pre><code>File "models.py" in validate_unique
    125.         slugfodder = u'%s %s' % (self.cohort.year_group.shortname, self.name)
  File "/usr/local/lib/python2.6/dist-packages/django/db/models/fields/related.py" in __get__
    301.                 raise self.field.rel.to.DoesNotExist
  </code></pre>
  
  <p>In pdb:</p>
  
  <pre><code>-&gt; slugfodder = u'%s %s' % (self.cohort.year_group.shortname, self.name)
  (Pdb) self
  *** DoesNotExist:
  </code></pre>
  
  <p>So how is the admin site managing to validate against 'self'? Does my validation need to do something like <code>save(commit = False)</code>?</p>
  
  <p>I can of course add more detail, but I think what's relevant is here.</p>