Guest User

Untitled

a guest
Jun 20th, 2018
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.83 KB | None | 0 0
  1. import uuid
  2. from django.db import models
  3. from django.utils.text import gettext_lazy as _
  4. from .models import Course, Instructor
  5.  
  6.  
  7. class CourseTimeline(models.Model):
  8. id = models.UUIDField(
  9. _('id'),
  10. default=uuid.uuid4,
  11. primary_key=True,
  12. editable=False,
  13. unique=True
  14. )
  15. instructor = models.ForeignKey(Instructor, verbose_name=_('instructor'), related_name='courses', on_delete=models.CASCADE)
  16. course = models.ForeignKey(Course, verbose_name=_('course'), related_name='instructors', on_delete=models.CASCADE)
  17. start = models.DateField(_('start date of the course'))
  18. end = models.DateField(_('end date of the course'))
  19.  
  20. class Meta:
  21. db_table = 'courses_timeline'
  22.  
  23. def __str__(self):
  24. return '%s %s (%s-%s)'%(self.instructor, self.course, self.start, self.end)
Add Comment
Please, Sign In to add comment