down votefavorite 
<http://stackoverflow.com/questions/38966759/shift-date-not-updated-as-sit-date#>

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 Date2016-09-01       Sept. 15, 20162016-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?

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/271b2d7e-c5d1-4981-9e97-d5fb8b18f47a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to