给定导入错误,即使我已导入模型类?

时间:2015-07-23 07:45:09

标签: python django django-models

我有像这样的models.py

from notifications.models import SignupInfoEmail

    class Request(models.Model):
        created = models.DateTimeField(auto_now_add=True, editable=False)
        modified = models.DateTimeField(auto_now=True, editable=False)
        last_contacted = models.DateTimeField(editable=False, null=True, blank=True)

        first_name = models.CharField(max_length=50)
        last_name = models.CharField(max_length=50)
        email = models.EmailField()
        phone = models.CharField(max_length=30,null=True, blank=True)
        zipcode = models.CharField(max_length=5,null=True, blank=True)

        def __unicode__(self):
           return str(self.email)

        def send_info(self):
           first_name = self.first_name
           price = self.plan().calculate_price()
           #from notifications.models import SignupInfoEmail
           if self.status.upper() == "NEW":
              self.status = "info sent"
           self.last_contacted = datetime.datetime.now()
           self.save()
           return SignupInfoEmail.objects.send_info(self, self.email, first_name, price, self.info_url())

当我调用send_info函数时,它给出 ImportError:无法导入名称SignupInfoEmail ,即使我已经从通知模型导入了SignupInfoEmail。我尝试从文件顶部删除import语句并在send_info函数(注释声明)中写入import语句然后工作正常。为什么?是什么原因?

0 个答案:

没有答案