I want to create a row in one of my databases’ tables every time a row in a particular table is created.
For example:
class Group(models.Model):
name = models.CharField(max_length=50)
slug = models.SlugField(unique = True)
about = models.TextField(blank = True, null=True)
every time a new row in this table is created, I want to add a new row in a Link class
class Link(models.Model):
name = models.CharField(max_length=50)
slug = models.SlugField(unique = True)
location = models.CharField(max_length= 200)
Where the group’s slug will be the a part of the Link’s location.
How can I do that?
This is where the
post_savesignal comes in. You could add this to the bottom of your models.py: