Say I have 2 models:
User
Customer
They both have the following SHARED fields:
First name
Last name
Pin code
Id
They also have a shared save() method:
def save(self, *args, **kwargs):
if not self.pk:
id = secrets.token_urlsafe(8)
while User.objects.filter(id=id).count() != 0:
id = secrets.token_urlsafe(8)
self.id = id
super(User, self).save(*args, **kwargs)
How could I create a Base model that they can extend so that I don't need to define all of these things twice? Thanks!!