我正在开发一个测验应用程序,需要显示要进行的测验我的模型 .py 看起来像这样
from django.db import models
from django.contrib.auth.models import User
from django.contrib import admin
#######################
#Quiz Structure Models#
#######################
class Quiz(models.Model):
name = models.CharField(max_length = 255)
creation = models.DateField(auto_now_add=True)
creator = models.ForeignKey(User)
def __unicode__ (self):
return self.name
def possible(self):
total = 0
for question in self.question_set.all():
question.save()
total += question.value
return total
class Question(models.Model):
question = models.CharField(max_length = 255)
quiz = models.ForeignKey(Quiz)
creator = models.ForeignKey(User)
creation = models.DateField(auto_now_add = True)
#objective = TODO: include standards linking in later versions …Run Code Online (Sandbox Code Playgroud)