'How to remove unique constraint for a model attribute of an abstract model after inheritance?

I have an abstract class as:

class AbstractExecutive(models.Model):
    mobile = models.CharField(max_length=10,unique=True,
                              verbose_name='*Mobile')

   #other attributs not required....
    class Meta:
        abstract = True

I am inheriting this class to create different instances like Client,Vendor etc. For a class instance Client, I require that the unique constraint is dropped, while it exists for other class objects. I am using postgresql 9.1 I I dropped the the client table constraint using psql, but since the model is inherited, it always has unique constraint on it. Please note the Client table has data and cannot be disturbed. How can I get rid of the constraint in the table. Client class model:

class Client(AbstractAddress,AbstractExecutive):

    number = models.CharField(max_length=10,verbose_name='number',
                                  unique=True)
    #other attributes...


Solution 1:[1]

Unfortuanately this is not possible in django (https://docs.djangoproject.com/en/dev/topics/db/models/#field-name-hiding-is-not-permitted). You need to remove mobile from your abstract class and put it to the concrete classes (either with or without unique).

Solution 2:[2]

Maybe it wasn't possible with old Django versions, but now the solution is to re-define the attribute on the child class, without the unique=True constraint.

So in the given example, with the unique mobile attribute in the AbstractExecutive abstract model and that must not be unique in Client model:

Your abstract class:

class AbstractExecutive(models.Model):
    mobile = models.CharField(max_length=10, unique=True,
                              verbose_name='*Mobile')

   #other attributs not required....
    class Meta:
        abstract = True

The child non-abstract class:

class Client(AbstractAddress, AbstractExecutive):
    mobile = models.CharField(max_length=10, verbose_name='*Mobile')

    #other attributes...

When generating the migrations, the unique constraint will be removed in Client model.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Serafeim
Solution 2 pierreben