2

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)
K.Mert
  • 21
  • 3
  • 1
    Possible duplicate of [Django - Set Up A Scheduled Job?](https://stackoverflow.com/questions/573618/django-set-up-a-scheduled-job) – Plebala Aug 09 '19 at 12:57

1 Answers1

0

I would take a look in the django docs here: https://docs.djangoproject.com/en/2.2/howto/custom-management-commands/

Janik Spies
  • 399
  • 7
  • 15