模型.py
class StudentProfile(models.Model):
student = models.OneToOneField(
User, related_name='student', primary_key=True, parent_link=True, on_delete=models.CASCADE)
membership_end = models.DateTimeField(
verbose_name="Membership End Date", default=now, editable=False)
objects = StudentProfileManager()
管理者.py
class StudentQuerySet(models.QuerySet):
def get_student_chat_list(self):
return self.filter(membership_end >= datetime.Now()).values_list('student_id', 'chat_user_sid')
class StudentProfileManager(models.Manager):
def get_queryset(self):
return StudentQuerySet(self.model, using=self._db)
def get_student_chat_list(self):
return self.get_queryset().get_student_chat_list()
这应该有一个非常简单的解释,但我不明白这里有什么问题。我收到以下错误:
NameError: name 'membership_end' is not defined