Reverse for 'vote' with arguments '('',)' and keyword arguments '{}' not found.


如图 请输入图片描述

请输入图片描述

请输入图片描述

请输入图片描述

我选择选项 就没错,因为没触发异常, 当我不选择 的时候提交,就触发了视图异常导致错误 半天没找到错在哪里了, help me . thanks 请输入图片描述

请输入图片描述

model:

 from django.db import models

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

class track(models.Model): question = models.CharField(max length=200) pub date= models.DateTimeField('date published')


 def __unicode__(self):
    return self.question

def was_published_recently(self):
    now=timezone.now()
    return now-datetime.timedelta(days=1) <= self.pub_date < now

was_published_recently.admin_order_field = 'pub_date'
was_published_recently.boolean = True
was_published_recently.short_description = 'Published recently?'

class choice(models.Model): track = models.ForeignKey(track) choice text = models.CharField(max length=200) votes = models.IntegerField(default = 0)


 def __unicode__(self):
    return  self.choice_text

django django1.5.1

fready 10 years, 7 months ago

class MyDetailView(generic.DetailView):
model = News
#context_object_name = 'new'
template_name = 'news/detail.html'

我也遇到了同样的问题,现在解决了。要把页面中传的参数名,赋值给context_object_name 。

神秘君17号 answered 10 years, 7 months ago

Your Answer