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

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(maxlength=200) pubdate= 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) choicetext = models.CharField(maxlength=200) votes = models.IntegerField(default = 0)

def __unicode__(self):
    return  self.choice_text


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

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

【热门文章】
【热门文章】