I'm trying to add the save-function inside my models.py, but it seems I'm doing something wrong. The user has to type the first- and last-name. Without him or her entering any more data, another field inside my models.py should be filled with a combination from these fields.
models.py:
class Coworker(models.Model):
first_name = models.CharField(max_length=50, null=False, blank=False)
last_name = models.CharField(max_length=50, null=False, blank=False)
full_name = models.CharField(max_length=100, null=False, blank=False)
def save(self, *args, **kwargs):
self.full_name = self.first_name + " " + self.last_name
super().save(*args, **kwargs)
Is this even possible? Thanks for all your help.
Have a nice weekend!