title: Django Model Manage UNIQUE constraint error in save method
body: <p>this is with Python 3.8 and Django 3.1.3</p>
  <p>I have a model with an unique field</p>
  <pre><code>class SomeModel(models.Model):
      name = models.CharField(max_length=200, unique=True)
  </code></pre>
  <p>i'm searching a way to automatically change the field value if there is an UNIQUE constraint violation</p>
  <p>If i create a new instance with name =&quot;kevin&quot; while another instance already exists with the same name =&quot;kevin&quot;, it would change the name of the new instance with a suffix when save() is called</p>
  <p>eg : database is empty</p>
  <pre><code>&gt;&gt;&gt; foo = SomeModel()
  &gt;&gt;&gt; foo.name = &quot;kevin&quot;
  &gt;&gt;&gt; foo.save()
  
  # again
  &gt;&gt;&gt; foo = SomeModel()
  &gt;&gt;&gt; foo.name = &quot;kevin&quot;
  &gt;&gt;&gt; foo.save()
  
  # and again
  &gt;&gt;&gt; foo = SomeModel()
  &gt;&gt;&gt; foo.name = &quot;kevin&quot;
  &gt;&gt;&gt; foo.save()
  
  
  &gt;&gt;&gt; for foo in SomeModel.objects.all():
  &gt;&gt;&gt;    print(foo.name)
  
  kevin
  kevin_01
  kevin_02
  </code></pre>
  <p>didn't find the way to do this, i suppose i have to override the save method and catch the unique constraint error to do that. any ideas ?
  Thanks</p>