Python Django投票:按投票排序列表时没有默认管理器错误
我正在建立一个问答网站,并在模板上列出问题。我使用django投票对列表中的每个问题进行上/下投票,我希望按照投票数的顺序显示问题,从高到低 我将Django通用聚合添加到我的应用程序中,出现以下错误:Python Django投票:按投票排序列表时没有默认管理器错误,python,html,django,django-voting,Python,Html,Django,Django Voting,我正在建立一个问答网站,并在模板上列出问题。我使用django投票对列表中的每个问题进行上/下投票,我希望按照投票数的顺序显示问题,从高到低 我将Django通用聚合添加到我的应用程序中,出现以下错误: 'GenericForeignKey' object has no attribute '_default_manager' 怎么了 这是我的模型: #models.py class Question(models.Model): movie = m
'GenericForeignKey' object has no attribute '_default_manager'
怎么了
这是我的模型:
#models.py
class Question(models.Model):
movie = models.ForeignKey(Movie, blank=True, null=True)
question_text = models.CharField(verbose_name = "Question", max_length = 100)
q_pub_date = models.DateTimeField(auto_now_add = True)
q_author = models.ForeignKey(User)
观点:
#views.py
def questions(request, movie_id):
p = Movie.objects.get(pk=movie_id)
k = Question.objects.filter(movie = p).order_by('-q_pub_date')
top = generic_annotate(k, Vote.object, Sum('vote'))
return render_to_response('qanda/questions.html',
{'the_question':top}
context_instance = RequestContext(request))
还有我的模板(没有投票表格的话就删去了):
#questions.html
{u question%}中的问题为%
{{question.question_text}
{%endfor%}
如何消除此错误并以正确的顺序显示问题
#questions.html
{% for question in the_question %}
<p>{{ question.question_text }}
{% endfor %}