Hello Djangonauts, I get a NameError and I don't know why, I'm really getting mad. What I want to do is to list the number of Lessons a Student has passed.
My schoolutil/student model looks like this: from django.db import models from schoolutil.lesson.models import * class Student(models.Model): first_name = models.CharField('Vorname', max_length=30) last_name = models.CharField('Name', max_length=30) username = models.CharField('Benutzername', max_length=15, unique=True) password = models.CharField('Passwort', max_length=15) active = models.BooleanField('Aktiv?') street = models.CharField('Strasse', max_length=30) street2 = models.CharField('Zusatz zur Strasse', max_length=30, blank=True) zip = models.CharField('PLZ', max_length=8) city = models.CharField('Ort', max_length=30) phonenumber = models.CharField('Telefonnummer', max_length=15) email = models.EmailField('E-Mail', max_length=30) def __unicode__(self): return self.first_name + ' ' + self.last_name def fullName(self): return '%s %s' % (self.first_name, self.last_name) def LessonHours(self): l = Lesson.objects.all() return len(Lesson.objects.filter(student__email__exact='[EMAIL PROTECTED]')) I'm getting the following error: File "/home/daniel/work/schoolutil/../schoolutil/student/models.py", line 28, in LessonHours l = Lesson.objects.all() NameError: global name 'Lesson' is not defined But I _did_ import that (second line of the model). I also tried it with try...except, and there is no exception when importing schoolutil.lesson.models. Please note that the object filter in LessonHours() is not correct. For testing, I've hardcoded an email address. What am I doing wrong? --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---