I am now making a website where teachers announce assignments and students submit them. I made boards that they can post their announcements or submission but do not know how to check those who did not submit their homework. I want some functions that run automatically at the designated time (in this case, on the due date of the assignment, the function judges and gathers who did not get their homework done)
I looked for some libraries related to datetime but have no idea.
assignments/models.py
class Assignment(models.Model):
group = models.ForeignKey(Group, on_delete=models.CASCADE)
index_in_group = models.IntegerField()
title = models.CharField(max_length=30, verbose_name='name')
content = models.TextField(verbose_name=content')
due_date = models.DateTimeField(verbose_name='due')
created_at = models.DateTimeField(auto_now_add=True)
class Done(models.Model):
assignment = models.ForeignKey(Assignment, on_delete=models.CASCADE)
index_in_assignment = models.IntegerField()
author = models.ForeignKey(settings.AUTH_USER_MODEL, on_delete=models.CASCADE)
done_img = models.ImageField(upload_to='AssignmentsDone')
injung = models.IntegerField(default=0)
created_at = models.DateTimeField(auto_now_add=True)
The function would be like this: (not the exact one - just memo)
def check_submission(request, assignment_id):
members = Members of the group (I will retrieve this thoroughly when actually code)
submissions = Done.objects.filter(assignment.id = assignment_id)
did_hw = [x.author for x in submissions]
for member in members:
if member not in did_hw:
mark as unsubmitter
This post got too long.. but the question is actually so simple. I just wanna know if there is a way I can make a function work at a certain designated time user inputs.