title: Python Inheritance with unique attribute in master class
body: <p>I'm with a little problem.</p>
  <pre class="lang-py prettyprint-override"><code>class Person(models.Model):
      cpf = BRCPFField(**unique=true**)
  
  
  class Student(Person):
      new_field = ....
  
  
  class Teacher(Student):
      another_field = ...
  
  
  class BoardMember(Person):
      class Meta:
          proxy = True
  </code></pre>
  <p><em><strong>CPF = USA SSN.</strong></em></p>
  <p>A person can be a student, a board member and a student can be a teacher in future.</p>
  <p>When I register a person with a cpf, it's ok. But when I try to register the same person as a student, python show me a error because of the unique field. How can I solve this?</p>
  <p>Forms:</p>
  <pre class="lang-py prettyprint-override"><code>class PersonForm(forms.ModelForm):
      class Meta:
          model = Person
          fields = '__all__'
  
  
  class BoardMemberForm(PersonForm):
     class Meta:
          model = BoardMember
          fields = '__all__'
  
  
  class StudentForm(PersonForm):
     class Meta:
          model = Student
          fields = '__all__'
  </code></pre>
  <p>Views:</p>
  <pre class="lang-py prettyprint-override"><code>class StudentCreate(LoginRequiredMixin, CreateView):
      model = Student
      form_class = StudentForm
      login_url = reverse_lazy('users:login')
  
  
  class BoardMember Create(LoginRequiredMixin, CreateView):
      model = BoardMember
      login_url = reverse_lazy('users:login')
      form_class = BoardMemberForm
  </code></pre>
  <p>Template Student_form:</p>
  <pre class="lang-html prettyprint-override"><code>&lt;form class=&quot;row gx-3 gy-2 align-items-center needs-validation&quot; method=&quot;post&quot; action=&quot;&quot;
        role=&quot;form&quot; enctype=&quot;multipart/form-data&quot;&gt;
      {% csrf_token %}
      {{ form.media }}
      &lt;div class=&quot;row g-3&quot;&gt;
          &lt;div class=&quot;col-md-3&quot;&gt;
              &lt;div class=&quot;form-floating&quot;&gt;
                  {{ form.cpf }}
                  &lt;label for=&quot;id_cpf&quot;&gt;CPF&lt;/label&gt;
              &lt;/div&gt;
          &lt;/div&gt;
          &lt;div class=&quot;col-md-6&quot;&gt;
              &lt;div class=&quot;form-floating&quot;&gt;
                  {{ form.nome }}
                  &lt;label for=&quot;id_nome&quot;&gt;Nome&lt;/label&gt;
              &lt;/div&gt;
          &lt;/div&gt;            
      &lt;/div&gt;           
      &lt;div class=&quot;col-auto&quot;&gt;
          &lt;button type=&quot;submit&quot; class=&quot;btn btn-primary mb-2&quot;&gt;Enviar&lt;/button&gt;
      &lt;/div&gt;
  &lt;/form&gt;
  </code></pre>
  <p>Template BoardMember_form:</p>
  <pre class="lang-html prettyprint-override"><code>&lt;form class=&quot;row gx-3 gy-2 align-items-center needs-validation&quot; method=&quot;post&quot; action=&quot;&quot;
        role=&quot;form&quot; enctype=&quot;multipart/form-data&quot;&gt;
      {% csrf_token %}
      {{ form.media }}
      &lt;div class=&quot;row g-3&quot;&gt;
          &lt;div class=&quot;col-md-3&quot;&gt;
              &lt;div class=&quot;form-floating&quot;&gt;
                  {{ form.cpf }}
                  &lt;label for=&quot;id_cpf&quot;&gt;CPF&lt;/label&gt;
              &lt;/div&gt;
          &lt;/div&gt;
          &lt;div class=&quot;col-md-6&quot;&gt;
              &lt;div class=&quot;form-floating&quot;&gt;
                  {{ form.nome }}
                  &lt;label for=&quot;id_nome&quot;&gt;Nome&lt;/label&gt;
              &lt;/div&gt;
          &lt;/div&gt;
         &lt;div class=&quot;col-md-6&quot;&gt;
              &lt;div class=&quot;form-floating&quot;&gt;
                  {{ form.function }}
                  &lt;label for=&quot;id_nome&quot;&gt;Function&lt;/label&gt;
              &lt;/div&gt;
          &lt;/div&gt;            
      &lt;/div&gt;           
      &lt;div class=&quot;col-auto&quot;&gt;
          &lt;button type=&quot;submit&quot; class=&quot;btn btn-primary mb-2&quot;&gt;Enviar&lt;/button&gt;
      &lt;/div&gt;
  &lt;/form&gt;
  </code></pre>