AttributeError:类型对象“ ClassName”没有属性“ object”

时间:2018-07-27 00:18:22

标签: python django-models django-rest-framework attributeerror

这是我的models.py:

from django.db import models
from django.utils import timezone

class SelectScent(models.Model):
   client = models.ForeignKey('auth.User', 
   on_delete=models.CASCADE)
   scent = models.CharField(max_length=300)
   text = models.TextField()
   created_date = models.DateTimeField(
        default=timezone.now)
   select_date = models.DateTimeField(
        blank=True, null=True)

   def publish(self):
       self.select_date = timezone.now()
       self.save()

   def __str__(self):
       return self.scent

当我键入SelectScent.objects.all()时,出现上述错误。 python版本:3.6.1

0 个答案:

没有答案