【发布时间】:2013-11-19 10:42:08
【问题描述】:
我有 Views.py
class newChartView(TemplateView):
template_name = "new_report_view.html"
def get_context_data(self, **kwargs):
context = super(newChartView, self).get_context_data(**kwargs)
context['count'] = smslogger.objects.all()
return context
和 new_report_view.html 作为
{% for x in count %}
{{ x.count }}
{% endfor %}
显示错误
'module' object has no attribute 'objects'
短信记录器
model
class Log(models.Model):
date= models.DateField()
count=models.CharField(max_length=100)
class Meta:
verbose_name_plural = "SMS Log"
def __unicode__(self):
return self.date,self.count
我想从 smslogger 应用程序中获取数据。如何通过 TemplateView 子类实现它
【问题讨论】:
-
smslogger 必须是模型而不是应用程序
-
应用没有数据。模型可以。
-
你能和我们分享一下smslogger模型吗?这将有助于找出问题。