mercredi 27 juin 2018

How can I create django model which implement lesson in timetable?

I'm trying to create a timetable system for classroom in Django. I have an idea which I am still wondering that i will work or not. Here is the model represent each lesson in class; lesson 1(7:00 AM - 7:50), lesson 2(7:50 - 8:40), etc.

class Lesson(models.Model):
start = models.TimeField()
end = models.TimeField()
lesson = models.PositiveSmallIntegerField(choices=[(i, i) for i in range(1, 10)], primary_key=True)

class Meta:
    verbose_name = 'lesson'
    ordering = ['lesson']

def __str__(self):
    return "{}".format(self.lesson)

What I need here is creating 10 lessons starting from 7:00 am and lasting 50 minutes each. I'd love to here your precious advises. Thank you.




Aucun commentaire:

Enregistrer un commentaire