Created
July 11, 2019 04:45
-
-
Save ihfazhillah/ef4b170abd409e79873153c9b379dda7 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.db import models | |
class Teacher(models.Model): | |
name = models.CharField() | |
class Student(models.Model): | |
name = models.CharField() | |
class Quiz(models.Model): | |
title = models.CharField() | |
description = models.TextField() | |
created_by = models.ForeignKey(Teacher) | |
students = models.ManyToMany(Student) | |
_is_expired = models.BooleanField(verbose_name='is_expired', default=False) | |
created_at = models.DateTimeField(auto_now_add=True) | |
@property | |
def is_expired(self): | |
if self._is_expired: | |
return True | |
# some logic to check expiration, and update the _is_expired to True if expired | |
return is_expired # assumed that is_expired defined | |
class Question(models.Model): | |
text = models.TextField() | |
quiz = models.ForeignKey(Quiz) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment