I have just begin the Django web framework and I am trying to make internship diary application. I want to create an model which has name as "RecordedWorkDay" automatically for each intern user. But these object should be created by program for each day. What I mean is if today is Monday, tomorrow new object should be created by program.
#That is my user class which extends from AbstractUser
class CustomizedUser(AbstractUser):
authory_choices = (
("İntern", "İntern"),
("Manager", "Manager"),
)
authory = models.CharField(choices=authory_choices, default="İntern", max_length=10)
school = models.CharField(max_length=200, default='')
description = models.CharField(max_length=100, default='')
city = models.CharField(max_length=100, default='')
def is_intern(self):
if self.authory == "İntern":
return True
return False
def is_manager(self):
if self.authory == "Manager":
return True
return False
#This class should save diary text for each day
class RecordedWorkDays(models.Model):
# TextField that holds users' working day records
record = models.TextField()
#Corresponding intern that owns this day object
assignedIntern = models.ForeignKey(CustomizedUser, related_name="assigned", null=True, blank=True, on_delete=models.SET_NULL)
creation_date = models.DateTimeField(default=datetime.now)