You can use ManyToMany relationships with = In your example, it will be something like the AddressType model
class Client(models.Model): addresses = ManyToManyField(Address, through=AddressType, related_name='address_clients') class AddressType(models.Model): type = models.CharField('Type', max_length=255, unique=True) client = models.ForeignKey(Client, related_name='client_address_types') address = models.ForeignKey(Address, related_name='address_client_types')
Now add 2 objects by admin and use it
In the future, if you want to add more types, you just need to add 1 type from the administrator)) for example, the work address
In mind that it is easy to use:
client = Client.objects.get(id=...) client_tmp_address = client.addresses.get(address_client_types_type='temporary') # If you added temporary Type before
source share