エラーが発生しています
グローバル名 'name' が定義されていません...
ラインのためにsubjects = Course...
。件名をクエリして、件名テンプレートで使用できるようにしたい
モデル
from django.db import models
from django.contrib.auth.models import User
class Course(models.Model):
name = models.CharField(max_length = 100)
stype = models.CharField(max_length = 100)
subject = models.CharField(max_length = 100)
location = models.CharField(max_length = 100)
class Teacher(models.Model):
username = models.ForeignKey(User,unique = True)
address = models.CharField(max_length = 200)
city = models.CharField(max_length = 50)
email_address = models.EmailField(max_length=75, unique = True)
class Student(models.Model):
username = models.ForeignKey(User,unique = True)
address = models.CharField(max_length = 200)
city = models.CharField(max_length = 50)
email_address = models.EmailField(max_length=75, unique = True)
class Attendance(models.Model):
course = models.ForeignKey(Course,unique = True)
student = models.ForeignKey(Student,unique = True)
teacher = models.ForeignKey(Teacher,unique = True)
date = models.DateField(unique = True)
status = models.BooleanField(unique = True)
created_at= models.DateTimeField(auto_now_add = True)
updated_at= models.DateTimeField(auto_now = True)
def subjects(request,username):
user = User.objects.get(username=username)
subjects = Course.objects.get(name = name)
variables = RequestContext(request,{
'username': username,
'subject' : subject
})
return render_to_response('subjects.html', variables)