I designed two models: one model for storing Sitting date and another mode for storing Shifting date. Two model are linked by foreign key. Here is my two models:
class Sitting(models.Model):
sit_date = models.DateField(blank=False,unique=True)
cut_off_date = models.DateField(null=True, blank=True)
ballot_date = models.DateField(null=True, blank=True)
sess_no = models.ForeignKey(Session,
on_delete=models.CASCADE)
genre = TreeForeignKey('Genre', null=True, blank=True, db_index=True)
Shift Model:
class Shiftdate(models.Model):
shift_date = models.DateField(blank=False,unique=True)
sit_date = models.ForeignKey(Sitting,
on_delete=models.CASCADE)
Using Shift model's shift_date, I changed existing sitting dates to other dates as:
Sitting Date Shifting Date
2016-09-01 Sept. 15, 2016
2016-09-08 Sept. 19, 2016
Now I want to make these shift date to a new sitting dates. For this I define following method in Sitting model:
def get_shift_date(self):
return self.sit_date= self.shift_date
And this shift_date to be saved in the Sitting model in sit_date field. I define following save method:
def save(self, *args, **kwargs):
self.sit_date = self.get_shift_date()
super(Sitting, self).save(*args, **kwargs)
But this did not return shift dates as sitting dates. Could someone help me to fix this codes?